What is T_PAAMAYIM_NEKUDOTAYIM syntax error?

Some people on older versions of PHP may encounter a Parse error message saying "syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)" and may wonder what it is. I remember creating a Scientific Calculator PHP code before, and while working on the code, I accidentally made a mistake on my syntax and trigger the same error message. And like many others, I was dumbfounded. It was weird because it was my first time stumbling on a non-English error message in PHP.

Here is a captured message back in 2018. Back then, the latest PHP was PHP 7.

T_PAAMAYIM_NEKUDOTAYIM
T_PAAMAYIM_NEKUDOTAYIM syntax error

We all know that T_PAAMAYIM_NEKUDOTAYIM is the token, but the word PAAMAYIM_NEKUDOTAYIM doesn't make sense. PHP does, however, try to give you an idea of what the error message is all about by hinting that there is an unexpected '::', and it was expecting ':' or ';'. Therefore, the problem here is obviously the double colon (::). PHP's manual also included it on its list of tokens. The double colon is use to allow access to static, constant, and overridden properties or methods of a class (see Scope Resolution Operator (::)). But, what does PAAMAYIM_NEKUDOTAYIM means?

Researching further, I found out that Paamayim Nekudotayim is actually a Hebrew word for "double colon" — פעמיים נקודתיים. The word was first introduced in the Israeli-developed Zend Engine 0.5, which was used to power PHP 3. It remained in PHP as a baggage until it was finally removed in PHP 8. The correct word should be "nekudatayim" instead of "nekudotayim", but it got misspelled.

On PHP 3-7, this error is triggered whenever you make a double colon mistake. See example code:

php code paamayim nekudotayim
A sample of a PHP code triggering a T_PAAMAYIM_NEKUDOTAYIM error.

The code in line 20 — default:: will trigger the T_PAAMAYIM_NEKUDOTAYIM error message because you used a "::" instead of a ":". This error will also show up if PHP is expecting a double colon, but found a different operator instead.

Leave a Reply

Your email address will not be published. Required fields are marked *