A basic question. thank you. EchoNULLfalse? & Quot; true & quot;: & quot; false & quot; output trueechofalse0? & Quot; true & quot;: & quot; false & quot; why is false output? EchoNULL0? & Quot. a basic question. thank you.
Echo NULL = false? "True": "false"; // outputs true
Echo false = '0 '? "True": "false"; // outputs true
Why is false output below?
Echo NULL = '0 '? "True": "false"; // outputs false
In PHP, variables are stored in a C-language structure. empty strings, NULL strings, and false are both stored with a value of 0.
The above sentence is correct.
------ Solution --------------------
Php is a weak language.
So when you change
Echo false = 0? "True": "false"; // outputs true
It is also true, so you can't simply judge '0' to say that it is a string type, because you use =
It does not compare the types
If you want to judge whether the string 0 is
Echo false = '0 '? "True": "false"; // outputs false
Discussion
Is false a string?
Why echo false = '0 '? "True": "false"; // outputs true
Reference:
'0' is a string. if it is null = "", it will be true.
------ Solution --------------------
Come and read the manual with me ....
Http://ca.php.net/manual/en/language.operators.comparison.php
Intermediate Comparison with Various Types table ....
For comparison of different types of variables, type conversion is required first, and how conversion determines the final result ....