How do I define it without defining it?
Is it similar to the if define in C language??
If you can find it in the PHP manual, please.
Like what:
defined('THINK_PATH') or define('THINK_PATH', dirname(__FILE__).'/');
Reply content:
How do I define it without defining it?
Is it similar to the if define in C language??
If you can find it in the PHP manual, please.
Like what:
defined('THINK_PATH') or define('THINK_PATH', dirname(__FILE__).'/');
There is also a "short circuit evaluation" of the knowledge points here.
PHP or C or many modern languages have this feature, in the calculation of logic or expression, the left side if true, then no longer calculate the right side, directly return true, so A or B;
the effect can be achieved if(!A) B;
Similarly, when the logic is calculated, if the left side is false, then a short circuit is also taken, and the right side is not counted to return false A and B;
likeif(A) B;
Short-circuit evaluation in the semantics of more close to English, but also to avoid the "if must be curly braces" brought about by the visual pollution (?), so it is more common practice (although not strictly in the sense of good habits)
http://php.net/manual/zh/function.defined.php
http://php.net/manual/zh/function.define.php
The =w= manual has ... defined () detects whether a constant name exists. return TRUE if defined returns False if not defined
Defined (' Think_path ') or define (' Think_path ', dirname (FILE). ' /');
First check that the constant think_path is defined, and if it is not defined, define a constant Think_path value dirname (FILE). ' /'
Similar to if (! A) {b} statement, but write to a or B words more introduction, if the definition of Think_path, then the condition is true, do not go behind, if not defined Think_path will go behind the statement.