有人有T_PAAMAYIM_NEKUDOTAYIM吗?
当前回答
对我来说,这发生在一个类函数中。
在PHP 5.3及以上版本中,$this::$默认值工作正常;当我把代码交换到一个服务器上时,不管出于什么原因,这个服务器的版本号更低,它抛出了这个错误。
解决方案,在我的情况下,是使用关键字self而不是$this:
Self::$defaults工作得很好。
其他回答
它是双冒号操作符::(参见解析器令牌列表)。
从维基百科:
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 5.3及以上版本中,$this::$默认值工作正常;当我把代码交换到一个服务器上时,不管出于什么原因,这个服务器的版本号更低,它抛出了这个错误。
解决方案,在我的情况下,是使用关键字self而不是$this:
Self::$defaults工作得很好。
希伯来语是"双冒号"的意思。
当你在PHP中对empty()函数应用常量时,也会出现这种情况:
if (!empty(SOME_CONSTANT)) {
}
那是我的案子。我用这个方法解决了这个问题:
$string = SOME_CONSTANT;
if (!empty($string)) {
}
推荐文章
- PHP与MySQL 8.0+错误:服务器请求身份验证方法未知的客户端
- laravel5“LIKE”对等物(雄辩的)
- 在函数中使用默认实参
- 转换php数组到Javascript
- PHP PDO:字符集,集名称?
- PHP函数生成slug (URL字符串)
- GCM与PHP(谷歌云消息传递)
- 如何在Symfony 2中获得请求参数?
- 我如何在PHP中输出一个UTF-8 CSV, Excel将正确读取?
- 如何初始化静态变量
- 如何将PDF文档转换为PHP预览图像?
- 如何插入元素到数组在特定的位置?
- 使用PHP加密和解密密码的最佳方法是什么?
- 如何实现一个好的脏话过滤器?
- PHP中的三个点(…)是什么意思?