I have the code below. How can I print directly “TRUE” or “FALSE”?
Should I go through an if, like "if … == TRUE echo “TRUE”?
If echo prints “TRUE” as “1”, why echo does not print “FALSE” as 0?
$test_false = FALSE;
$test_true = TRUE;
You will have to use an if.
$test = true;
if($test == true)
But if your variable is a string, then you don’t need that.
$test = "true";
I was afraid someone would say this
I always try to make something as simple as possible, with as few ifs as possible.
How about the second question?
>>> If echo prints “TRUE” as “1”, why echo does not print “FALSE” as 0?
You can do a one-liner though:
echo true === (bool)$test ? 'True' : 'False';
Can [fphp]var_dump()[/fphp] be an option aswell?
[fphp]var_export[/fphp] will do too