Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get "true"/"false" string values from a Boolean in PHP?

When I cast to Boolean (using (bool)), is there a built in way to get PHP to actually return the constants true or false. At the moment I'm getting 1 or blank, which evaluate to true and false respectively.

I want the value returned for clearer semantics. However, if I can't get it, I'll just settle with 1 and blank.

like image 963
alex Avatar asked Feb 12 '10 02:02

alex


1 Answers

In case you're too lazy to do a comparison and echo a string or if you just want to keep it short you can use :

var_export($boolean, true); // the second parameter is to return and not output

PHP: var_export

like image 149
kevin Avatar answered Oct 09 '22 21:10

kevin