$variable = (0 > 0)
For some reason, when I try to print $variable, it doesn't print anything. No null, nothing. But
$variable = (1 > 0)
sets $variable to true. Why is that, and what is the best way to do what I'm trying?
$variable is being set correctly -- you can see this with var_dump($variable).
The issue is that in PHP trying to straight print false and null values prints the empty string, so nothing appears to happen. var_dump is one of the ways to check what's really going on; when dealing with booleans, a more convenient way is to cast to int first:
echo (int)$variable; // prints "0" or "1"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With