PHP 需要 T_PAAMAYIM_NEKUDOTAYIM?

发布于 2024-07-14 15:18:02 字数 49 浏览 14 评论 0原文

有人有 T_PAAMAYIM_NEKUDOTAYIM 吗?

Does anyone have a T_PAAMAYIM_NEKUDOTAYIM?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

紫﹏色ふ单纯 2024-07-21 15:18:02

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

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

吻风 2024-07-21 15:18:02

希伯来语表示“双冒号”。

It's Hebrew for "double colon".

失退 2024-07-21 15:18:02

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

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

晌融 2024-07-21 15:18:02

来自维基百科

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

来自官方 PHP 文档

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

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

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

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

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!

染墨丶若流云 2024-07-21 15:18:02

我很懂希伯来语,所以为了向您澄清“Paamayim Nekudotayim”这个名字,释义的意思是“双冒号”,但按字面翻译:

  • “Paamayim”的意思是“两个”或“两次”
  • “Nekudotayim”的意思是“点”(点燃“洞”)
    • 在希伯来语中,nekuda 表示一个点。
    • 复数是nekudot,即点,起到元音的作用
    • 之所以叫 Nekudo-tayim 是因为后缀“-ayim”也有“两个”或“两次”的意思,因此 :: 表示“两个”次,两个点”,或更常见的名称是范围解析运算符

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

  • "Paamayim" means "two" or "twice"
  • "Nekudotayim" means "dots" (lit. "holes")
    • In the Hebrew language, a nekuda means a dot.
    • The plural is nekudot, i.e, dots, which function as vowels
    • The reason it why it's called Nekudo-tayim is because the suffix "-ayim" also means "two" or "twice", thus :: denotes "two times, two dots", or more commonly known as the Scope Resolution Operator.
2024-07-21 15:18:02

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

if (!empty(SOME_CONSTANT)) {

}

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

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

}

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

}
溺渁∝ 2024-07-21 15:18:02

编辑:不幸的是,从 PHP 8.0 开始,答案不再“不,不再”。 此 RFC 未如我所愿被接受,建议更改 T_PAAMAYIM_NEKUDOTAYIMT_DOUBLE_COLON; 但遭到拒绝。

注意:我保留这个答案是出于历史目的。 实际上,由于 RFC 的创建和某个时刻的投票比例,我创建了这个答案。 另外,我保留这个是为了希望它在不久的将来能被接受。

Edit: Unfortunately, as of PHP 8.0, the answer is not "No, not anymore". This RFC was not accepted as I hoped, proposing to change T_PAAMAYIM_NEKUDOTAYIM to T_DOUBLE_COLON; but it was declined.

Note: I keep this answer for historical purposes. Actually, because of the creation of the RFC and the votes ratio at some point, I created this answer. Also, I keep this for hoping it to be accepted in the near future.

夜还是长夜 2024-07-21 15:18:02

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

foreach( $array as $key = $value )

而不是

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

This can happen on foreachs when using:

foreach( $array as $key = $value )

instead of

foreach( $array as $key => $value )
放飞的风筝 2024-07-21 15:18:02

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

在 PHP 5.3 及以上版本 $this::$defaults 工作正常; 当我将代码交换到服务器时,由于某种原因,该服务器的版本号较低,它引发了此错误。

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

self::$defaults 工作得很好。

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.

泛滥成性 2024-07-21 15:18:02

这只是在使用双引号的字符串赋值中发生在我身上。 我缺少 POST 变量上的结束卷曲...

"for {$_POST['txtName'] on $date";

应该是

“for {$_POST['txtName']} on $date”

我无法解释为什么。 我的意思是,我看到了会破坏代码的错误,但我不明白为什么它引用了类错误。

This just happened to me in a string assignment using double quotes. I was missing a closing curly on a POST variable...

"for {$_POST['txtName'] on $date";

should have been

"for {$_POST['txtName']} on $date";

I can't explain why. I mean, I see the error that would break the code but I don't see why it references a class error.

拥抱影子 2024-07-21 15:18:02

这只是在 foreach 循环中发生在我身上。 我无意中输入了 ($array as $key as $value),而 PHP 拒绝了第一个 as

This just happened to me in a foreach loop. I had inadvertently typed ($array as $key as $value) and PHP objected to the first as.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文