简体   繁体   English

在处理常量时得到“期望T_PAAMAYIM_NEKUDOTAYIM”

[英]getting “expecting T_PAAMAYIM_NEKUDOTAYIM” when working with constants

i have the following piece of code in php: 我在php中有以下代码:

define('QUERY', $some_query_string);
if(empty(QUERY) || mb_strlen(QUERY) < 4):
    //worn the user about incorrect query input
endif;

when running this script i'm getting the fallowing error Parse error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM , but when i'm using an ordinary variable instead of constant everything works just fine! 当运行这个脚本时,我得到了以下Parse error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM ,但是当我使用普通变量而不是常量时,一切正常!

The usage of constant is not required, but i would appreciate if anyone could explain why i'm getting that error? 常量的使用不是必需的,但如果有人能解释为什么我得到那个错误,我将不胜感激?

(i'm newby here, so please tell me if i have to provide more details) (我是新来的,所以请告诉我是否需要提供更多细节)

empty only works with variables . empty只适用于变量 If you want to check whether a constant has been defined, use defined . 如果要检查是否已定义常量,请使用已defined The error messages invalid uses of empty produce aren't necessarily very intuitive, the message about T_PAAMAYIM_NEKUDOTAYIM mostly means the parser tripped up. 错误消息无效使用empty产品不一定非常直观,关于T_PAAMAYIM_NEKUDOTAYIM的消息主要意味着解析器被绊倒。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM