+ 4
[PHP] What does string 'false' evaluates?
Answer: boolean true. How? Can you give me example please? Here I tried: https://code.sololearn.com/wKAYAZ5G41oH/?ref=app
4 Answers
+ 3
Converting to a boolean causes all values to be evaluated to true except:
* the boolean FALSE itself
* the integer 0 (zero)the float 0.0 (zero)the empty string, and the string "0"
* an array with zero elements
* the special type NULL (including unset variables)
* SimpleXMLÂ objects created from empty tags
Obtained from
http://php.net/manual/en/language.types.boolean.php
Try writing
$x = '0', and the result will be false.
Also notice something random like:
$x = 'The sun is warm101', will result in true.
+ 2
When you write 'false' or 'true' those are strings not the boolean values true and false. And in PHP I believe non-empty strings are evaluated to be the boolean value true. That is why you were getting those results.
+ 2
Oh. Got it cyk Rrestoring faith. Thanks a lot :)
+ 1
Come on! Whoever downvoted this atleast should have posted the reason!
If you think this question is wrong, look where I found this question:
https://s.amsu.ng/KpaJ9l5xeTrN