简体   繁体   中英

getting “expecting T_PAAMAYIM_NEKUDOTAYIM” when working with constants

i have the following piece of code in 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!

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 . If you want to check whether a constant has been defined, use 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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