in Yii they use this code:
defined('YII_DEBUG') or define('YII_DEBUG',true);
i’ve never seen anyone write like this before (or). is this real php code or some syntax of yii?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s due to short circuit evaluation.
If
defined('YII_DEBUG')returnsfalse, it will try to evaluate the second expression to make the sentence true, definingYII_DEBUGconstant astrue.The final result is that, if the constant were not defined, then define it as being
true. If it’s already defined (the value doesn’t matter), then do nothing (as the first expression is true, the second expression does not need to be evaluated for the expression to be true).