PHP 需要 T_PAAMAYIM_NEKUDOTAYIM?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/592322/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 23:11:17  来源:igfitidea点击:

PHP expects T_PAAMAYIM_NEKUDOTAYIM?

phpsyntax-errorruntime-error

提问by Peter Turner

Does anyone have a T_PAAMAYIM_NEKUDOTAYIM?

有人有T_PAAMAYIM_NEKUDOTAYIM吗?

采纳答案by Gumbo

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

它是双冒号运算符::(请参阅解析器标记列表)。

回答by patricksweeney

Google works wonders.

谷歌创造奇迹。

It's Hebrewfor "double colon".

“双冒号”是希伯来语

回答by Ilya Birman

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 :-)

它是::PHP 中运算符的名称。它的字面意思是“双冒号”。出于某种原因,他们用希伯来语命名了它。检查您的代码语法,并::在适当的地方放一个:-)

回答by John Slegers

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)

在 PHP 中,范围解析运算符也称为 Paamayim Nekudotayim(希伯来语:?????? ?????????),在希伯来语中的意思是“双冒号”。

“Paamayim Nekudotayim”这个名字是在 PHP 3 中使用的以色列开发的 Zend Engine 0.5 中引入的。虽然很多不会说希伯来语的开发人员对此感到困惑,但它仍在 PHP 5 中使用,如本示例错误消息:

$ php -r :: 解析错误:语法错误,意外 T_PAAMAYIM_NEKUDOTAYIM

从 PHP 5.4 开始,关于作用域解析运算符的错误消息仍然包含这个名称,但已经稍微澄清了它的含义:

$ php -r :: 解析错误:语法错误,意外的 '::' (T_PAAMAYIM_NEKUDOTAYIM)

From the official PHP documentation:

来自官方 PHP 文档

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!

范围解析运算符(也称为 Paamayim Nekudotayim)或更简单的术语是双冒号,是一种标记,允许访问类的静态、常量和覆盖的属性或方法。

从类定义外部引用这些项时,请使用类的名称。

从 PHP 5.3.0 开始,可以使用变量来引用类。变量的值不能是关键字(例如 self、parent 和 static)。

Paamayim Nekudotayim 乍一看似乎是命名双冒号的奇怪选择。然而,在编写 Zend Engine 0.5(支持 PHP 3)时,Zend 团队决定将其命名为。它实际上确实意味着双冒号 - 在希伯来语中!

回答by Max

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

当您将 PHP 中的常量应用于 empty() 函数时,也会出现这种情况:

if (!empty(SOME_CONSTANT)) {

}

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

这就是我的情况。我用这个解决了它:

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

}

回答by Sapphire_Brick

I know Hebrew pretty well, so to clarify the name "Paamayim Nekudotayim" for you, the paraphrased meaning is "double colon", but translated literally:

我非常了解希伯来语,所以为了给你澄清“Paamayim Nekudotayim”这个名字,意译意思是“双冒号”,但按字面翻译:

  • "Paamayim" means "two" or "twice"
  • "Nekudotayim" means "dots" (lit. "holes")
    • In the Hebrew language, a nekudameans a dot.
    • The plural is nekudot, i.e, dots that act like vowels do in english.
    • The reason it why it's called Nekudo-tayimis because the suffix "-ayim" also means "two" or "twice", but it usually means two objects rather than two actions, thus ::denotes "two times, two dots", or more commonly known as the Scope Resolution Operator.
  • “Paamayim”的意思是“两个”或“两次”
  • “Nekudotayim”的意思是“点”(字面意思是“洞”)
    • 在希伯来语中,nekuda 的意思是一个点。
    • 复数是nekudot,即像英语中的元音一样的点。
    • 之所以叫Nekudo- tayim,是因为后缀“-ayim”也有“两个”或“两次”的意思,但它通常表示两个对象而不是两个动作,因此::表示“两次,两个点”或更多俗称范围解析运算符

回答by GDY

This can happen on foreachs when using:

使用以下命令时,这可能发生在 foreachs 上:

foreach( $array as $key = $value )

instead of

代替

foreach( $array as $key => $value )

回答by bozdoz

For me this happened within a class function.

对我来说,这发生在一个类函数中。

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

在 PHP 5.3 及更高版本中$this::$defaults工作正常;当我将代码交换到服务器时,无论出于何种原因,它的版本号较低,它都会引发此错误。

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

就我而言,解决方案是使用关键字self而不是$this

self::$defaultsworks just fine.

self::$defaults工作得很好。