PHP expects T_PAAMAYIM_NEKUDOTAYIM?

Does anyone have a T_PAAMAYIM_NEKUDOTAYIM?

转载于:https://stackoverflow.com/questions/592322/php-expects-t-paamayim-nekudotayim

csdnceshi79
python小菜 phpsadness.com/sad/1
接近 3 年之前 回复
weixin_41568184
叼花硬汉 No mistake. There are many valid pronunciation of the Hebrew vowel. Jews of Northern European and Yemenite descent use an oh sound, while Central European Jews say oo and African and Middle Eastern Jews say ah.
3 年多之前 回复
weixin_41568183
零零乙 I know this is an old question, but the short answer is that PHP is (mis-)interpreting a constant as a class name. Some operations, such as empty, won’t evaluate expressions which include constants. Therefore they will try to interpret a constant as a class name and expect it to have a :: to indicate a static property. And, of course, if you forget the $ on a variable, it is mis-interpreted as a constant. Much of this madness, if not the error message, is fixed in later versions of PHP.
接近 4 年之前 回复
csdnceshi59
ℙℕℤℝ The amount of standardization on PHP sometimes is so high that we end up getting error names from Hebrew :)
5 年多之前 回复
csdnceshi56
lrony* Another fix that may help others... Make sure your server is running the latest version of PHP!
接近 6 年之前 回复
csdnceshi57
perhaps? While all other languages choose to say something along the lines of _unexpected '::', PHP thinks to give more insight to the developers about their parser. Seriously? Someone should slap the PHP Dev team.
大约 6 年之前 回复
csdnceshi61
derek5. You're expected to be able to use an internet search engine, though.
6 年多之前 回复
csdnceshi71
Memor.の When i saw this error i just stared at the screen dumbstruck for some 30 seconds then burst out laughing and went to smoke a ciggarette :F 1+
接近 7 年之前 回复
weixin_41568134
MAO-EYE Such a stupid inconsistent feature of PHP. I <3 PHP but come on keep it consistent all errors in english or all in hebrew it's a programming language(or whatever) not a flavour of the month(the rest of the errors being in english).
接近 7 年之前 回复
weixin_41568126
乱世@小熊 why would you close the oldest one?
7 年多之前 回复
csdnceshi55
~Onlooker There are literally hundreds of similar questions here. stackoverflow.com/questions/2588298/… stackoverflow.com/questions/4995540/… stackoverflow.com/questions/5156781/…
7 年多之前 回复
csdnceshi73
喵-见缝插针 the spelling mistake is only the missing u. It should be T_PAAMAYIM_NEKUDOTAYIM. (PAAMAYIM = "twice", NEKUDOTAYIM = : = "נקודותיים")
7 年多之前 回复
weixin_41568126
乱世@小熊 I knew something about that error seemed amiss.
接近 8 年之前 回复
csdnceshi51
旧行李 hebrew for double double colon, but ... see bugs.php.net/bug.php?id=14492: "BTW, there is a spelling mistake in the parse error, it should be T_PAAMAYIM_NEKUDATAYIM (in hebrew, the 'double' form is just the original noun + the 'ayim' suffix and 'nekuda' is the single form ['nekudot' is the plural form])."
接近 8 年之前 回复
csdnceshi64
游.程 Sometimes this is PHP's way to tell you you are missing a $ sign... for example if you write _SESSION["foo"] instead of $_SESSION["foo"]
8 年多之前 回复
csdnceshi68
local-host <en.wikipedia.org/wiki/Paamayim_Nekudotayim>
11 年多之前 回复

8个回答

It’s the double colon operator :: (see list of parser tokens).

csdnceshi68
local-host var_dump(empty(TRUE)) , just return bool(false) in PHP 7.2
接近 2 年之前 回复
csdnceshi79
python小菜 For me, it was because I had (my own personal code example of the error) $tokenStatus = $tokenSystem->SecurityAuthenticationTokens::CheckAuthenticationToken($data['hashedPLToken']); I should NOT have had the :: (static) in there mixed with the -> operator since it was an instantiated class. My fix was... $tokenStatus = $tokenSystem->CheckAuthenticationToken($data['hashedPLToken']);
大约 4 年之前 回复
csdnceshi76
斗士狗 the reason that happens is because if you have a foreach($cats as cat the only acceptable character after the cat for a syntactically valid statement is a ::, as it would allow you to specify a static property of some class called cat. Eg, if cat class has a public static member called $mouse, then foreach($cats as cat::$mouse) is perfectly valid php, but a statement with anything other than :: after the cat would be a syntax error. If $mouse were not a declared property of cat you would get a fatal error, but still not a syntax error.
4 年多之前 回复
weixin_41568131
10.24 It shows when $ is missing from variable. I got it today and reached this post. In a foreach($cats as cat) then use the same cat in next line shows the error. But the answer says about :: and the person accepted it....??
大约 5 年之前 回复
csdnceshi56
lrony* Mandatory reading about the story of Paamayim Nekudotayim, which is also a case study in open source project professionalism.
5 年多之前 回复
csdnceshi66
必承其重 | 欲带皇冠 No. I just added an evaluation that returns the same T_PAAMAYIM_NEKUDOTAYIM. I found it by mistake.
6 年多之前 回复
csdnceshi67
bug^君 Wrong question/answer?
6 年多之前 回复
csdnceshi66
必承其重 | 欲带皇冠 Not really. Test this var_dump(empty(TRUE))
6 年多之前 回复

It’s a name for the :: operator in PHP. It literally means "double colon". For some reason they named it in Hebrew. Check your code syntax, and put a :: where appropriate :-)

csdnceshi51
旧行李 Ok, so on my next project I'll write some error code in Italian, I'm Italian! What do you expect, english everywhere? :-)
接近 5 年之前 回复
csdnceshi66
必承其重 | 欲带皇冠 The reason why it's in Hebrew is because the code was written by Israelis. I don't think they missed that error, They left it there untranslated as a reminder.
5 年多之前 回复
csdnceshi62
csdnceshi62 Highlight string is להדגיש מחרוזת. From now on, I will only use my custom array_push function לדחוף_מערך in Hebrew characters, of course. I'm sure all of my non-Hebrew speaking coworkers will love it. Just about all of our dev team speaks at least one language written in non-latin characters. Should be fun :)
接近 7 年之前 回复
csdnceshi72
谁还没个明天 Functions are in English, but that error is in Hebrew. I'm not sure if any other errors are in Hebrew though.
11 年多之前 回复

This is also coming when you apply a constant in PHP to the empty() function:

if (!empty(SOME_CONSTANT)) {

}

That was my case. I solved it by using this:

$string = SOME_CONSTANT;
if (!empty($string)) {

}
csdnceshi59
ℙℕℤℝ Panic: Why not? empty() not only tests if a variable exists, but also if it's value is "empty" (in case of PHP a zero (0) is also empty). Such a constant could represent a value which is meant to be changed by a user - like DB settings or some true / false values and other value types which the code developer don't know at design-time. This is common for APIs or code frameworks. I just don't understand why the developers of the Zend parser didn't used a common word that everybody knows and understands but instead some hebrew words. I mean, it's not even really funny or so.
5 年多之前 回复
weixin_41568174
from.. Nice Question : This is just for example if some else got in this error situation , i just show it will be also possible :)
接近 6 年之前 回复
weixin_41568184
叼花硬汉 Why would a constant be empty?
接近 6 年之前 回复

From Wikipedia:

In PHP, the scope resolution operator is also called Paamayim Nekudotayim (Hebrew: פעמיים נקודתיים‎), which means “double colon” in Hebrew.

The name "Paamayim Nekudotayim" was introduced in the Israeli-developed Zend Engine 0.5 used in PHP 3. Although it has been confusing to many developers who do not speak Hebrew, it is still being used in PHP 5, as in this sample error message:

$ php -r :: Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM

As of PHP 5.4, error messages concerning the scope resolution operator still include this name, but have clarified its meaning somewhat:

$ php -r :: Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)

From the official PHP documentation:

The Scope Resolution Operator (also called Paamayim Nekudotayim) or in simpler terms, the double colon, is a token that allows access to static, constant, and overridden properties or methods of a class.

When referencing these items from outside the class definition, use the name of the class.

As of PHP 5.3.0, it's possible to reference the class using a variable. The variable's value can not be a keyword (e.g. self, parent and static).

Paamayim Nekudotayim would, at first, seem like a strange choice for naming a double-colon. However, while writing the Zend Engine 0.5 (which powers PHP 3), that's what the Zend team decided to call it. It actually does mean double-colon - in Hebrew!

For me this happened within a class function.

In PHP 5.3 and above $this::$defaults worked fine; when I swapped the code into a server that for whatever reason had a lower version number it threw this error.

The solution, in my case, was to use the keyword self instead of $this:

self::$defaults works just fine.

Google works wonders.

It's Hebrew for "double colon".

csdnceshi72
谁还没个明天 about a new language that accepts any error, commits, syntax in any language? :) we can do it.
4 年多之前 回复

This is how I got it. I was trying out the limits of expressions in double quotes. So this is the code:

Code

$a = 5;

echo "{$a == 5 ? 'yes' : 'no'} its possible";

Output

  PHP Parse error:  syntax error, unexpected '==' (T_IS_EQUAL), expecting :: (T_PAAMAYIM_NEKUDOTAYIM) in php shell code on line 1

This can happen on foreachs when using:

foreach( $array as $key = $value )

instead of

foreach( $array as $key => $value )
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐