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?
<?php
$test_false = FALSE;
echo ($test_false);
$test_true = TRUE;
echo ($test_true);
?>
Jelena
March 10, 2006, 3:37pm
2
You will have to use an if.
$test = true;
if($test == true)
echo "TRUE";
But if your variable is a string, then you don’t need that.
$test = "true";
echo $test;
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?
Helge
March 10, 2006, 4:00pm
4
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