PHP - Get bool to echo false when false PHP - Get bool to echo false when false php php

PHP - Get bool to echo false when false


echo $bool_val ? 'true' : 'false';

Or if you only want output when it's false:

echo !$bool_val ? 'false' : '';


This is the easiest way to do this:

$text = var_export($bool_value,true);echo $text;

or

var_export($bool_value)

If the second argument is not true, it will output the result directly.


This will print out boolean value as it is, instead of 1/0.

    $bool = false;    echo json_encode($bool);   //false