PHP boolean TRUE / FALSE? -
I do not understand this.
If I write:
function myfunction () {...... if ... return true; If ... return is wrong; }
Why can not I use it:
$ result = myfunction (); If ($ result == true) ... if ($ result == wrong) ...
Or I have to use it:
$ Result = myfunction (); If ($ result == 1) ... if ($ result == 0) ...
or this:
$ result = myfunction (); If ($ result) ... if (! $ Result) ...
I can not fully understand your question, but you can do use any of the examples provided with the following alerts:
If you (If = a == TRUE)
(or, because the comparison of true
is redundant, just if (a)
), then you should understand PHP will evaluate several things as truth: 1, 2, 987, "Hello", etc.; They are all "true" values. It is rarely an issue, but you should understand it.
However, if the function can return more than true
or false
, you may be interested in ===
Using the ===
compares the type of variable: "a" == true
is true
, but " A "== = true
is wrong.
Comments
Post a Comment