Question #7   Submitted by Answiki on 04/27/2020 at 07:00:36 PM UTC

How to get the boolean value of a PHP variable ?

Answer   Submitted by Answiki on 04/27/2020 at 07:57:07 PM UTC

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 Answiki on 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 Answiki on 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 Answiki on 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 Answiki on 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 Answiki 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.