When I cast to Boolean (using (bool)), is there a built in way to get PHP to actually return the constants true or false. At the moment I’m getting 1 or blank, which evaluate to true and false respectively.
I want the value returned for clearer semantics. However, if I can’t get it, I’ll just settle with 1 and blank.
PHP displays boolean values as 1 (true) or empty string (false) when outputted.
If you want to check if it’s
trueorfalseuse==(if implicit conversion is OK) or===(if it’s not). For example:I don’t know of any way to make PHP output boolean values natively as
trueorfalse.