有人有T_PAAMAYIM_NEKUDOTAYIM吗?
当前回答
这只是发生在我的字符串赋值使用双引号。我在一个POST变量上缺少一个右花括号…
" {$_POST['txtName']在$date";
应该是
{$_POST['txtName']} on $date";
我不能解释为什么。我的意思是,我看到了会破坏代码的错误,但我不明白为什么它引用了类错误。
其他回答
从维基百科:
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官方文档:
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!
它是双冒号操作符::(参见解析器令牌列表)。
当你在PHP中对empty()函数应用常量时,也会出现这种情况:
if (!empty(SOME_CONSTANT)) {
}
那是我的案子。我用这个方法解决了这个问题:
$string = SOME_CONSTANT;
if (!empty($string)) {
}
编辑:不幸的是,从PHP 8.0开始,答案不再是“不,不再是”。这个RFC没有像我希望的那样被接受,建议将T_PAAMAYIM_NEKUDOTAYIM改为T_DOUBLE_COLON;但它被拒绝了。
注意:我保留这个答案是为了历史目的。实际上,由于RFC的创建和某些时候的投票比例,我创建了这个答案。另外,我保留这个,希望它在不久的将来被接受。
这只是发生在我的字符串赋值使用双引号。我在一个POST变量上缺少一个右花括号…
" {$_POST['txtName']在$date";
应该是
{$_POST['txtName']} on $date";
我不能解释为什么。我的意思是,我看到了会破坏代码的错误,但我不明白为什么它引用了类错误。
推荐文章
- 如何将XML转换成PHP数组?
- 如何将对象转换为数组?
- 从IP地址获取位置
- 获取数组值的键名
- HTTPS和SSL3_GET_SERVER_CERTIFICATE:证书验证失败,CA is OK
- PHP -获取bool值,当为false时返回false
- 在foreach中通过引用传递
- 如何触发命令行PHP脚本的XDebug分析器?
- 如何找出如果你使用HTTPS没有$_SERVER['HTTPS']
- 更好的方法检查变量为null或空字符串?
- 当使用Composer的开发/生产开关时,如何正确部署?
- 自动删除Laravel (Eloquent ORM)中的相关行
- 在取消设置元素后重新设置数组键
- 如何修剪空白的数组值在php
- PHP中的双not(!!)操作符