PHP boolval function (PHP 5 >= 5.5.0)

Udemy Generic 728x90

boolval is a php function, added in PHP 5.5 . It returns boolean value of given variable.


boolval function is available in PHP 5.5 and  higher version so before using boolval function, please make sure that you are using compatible PHP version .


boolval function accepts a variable and returns boolean value against given variable. It has following  syntax -

boolean boolval ( mixed $var) ;


<br />
<p>    function  getBooleanValue( $var ) {</p>
<p>        if(function_exists('boolval')) {</p>
<p>            $booleanValue = boolval($var);</p>
<p>        } else {</p>
<p>            $booleanValue = &quot;boolval function is not available in current environment , please check your PHP version&quot;;</p>
<p>        }</p>
<p>        return $booleanValue;</p>
<p>    }</p>
<p>    $booleanValue = getBooleanValue( 'Numetric');</p>
<p>    var_dump( $booleanValue);</p>




Udemy Generic 728x90

Spread the word. Share this post!