Pre-recorded question

Question #7
How to get the boolean value of a PHP variable ?
Answer

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

5 events in history
Answer by Alphonsio 04/27/2020 at 07:57:07 PM

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

Answer by Alphonsio 04/27/2020 at 07:56:50 PM

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


Answer by Alphonsio 04/27/2020 at 07:19:47 PM

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 ('string'); // true
boolval ('0'); // false
boolval ('1'); // true
boolval (null); // false


Answer by Alphonsio 04/27/2020 at 07:18:57 PM

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 ('string'); // true
boolval ('0'); // false
boolval ('1'); // true
boolval (null); // true


Question by Alphonsio 04/27/2020 at 07:00:36 PM
How to get the boolean value of a PHP variable ?
# ID Query URL Count

Icons proudly provided by Friconix.