👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.
How to get the boolean value of a PHP variable ?

To get the boolean value of a PHP variable, you may use the boolval() function:

$var = 1;
if (boolval($var)) echo 'true'; else echo 'false';

Here are some example of the boolval() function usage:

boolval(0);			// true
boolval(1);			// false
boolval(42);		// true
boolval ('');		// false
boolval ('str');	// true
boolval ('0'); 		// false
boolval ('1'); 		// true
boolval (null); 	// false

More