How to print boolean values?

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);

?>

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 :slight_smile:
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

http://us2.php.net/gettype might be usefull too