PHP | boolval() Function Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The boolval() function is an inbuilt function in PHP which gives the Boolean value for a given expression. Syntax: boolean boolval( $expr ) Parameter: This function accepts only one parameter as shown in above syntax and described below: $expr: The expression or the scalar which you want to change into boolean value. It can be a string type, integer type and etc. Return Value: This function will return a boolean value based on the below conditions. if $expr is evaluated to boolean true it will return TRUE. if $expr is evaluated to boolean false it will return FALSE. Below is the list of different variable types along with their values which will evaluate to TRUE or FALSE when converted to boolean value: integer – in this 0 is false and everything else is true. float – in this 0.0 is false and everything else is true. string – “0” and null string are false and everything else is true (even “0.0”) array – empty array is false and everything else is true object – here null is false and everything else is true null – null is always false. Below program illustrate the boolval() function in PHP: PHP <?php // PHP program to illustrate // the boolval() function echo 'boolval of 3: '.( boolval( 3 )? 'true' : 'false')."\n"; echo 'boolval of -3 : '.( boolval( -3 )? 'true' : 'false')."\n"; echo 'boolval of 0: ' .( boolval( 0 )? 'true' : 'false')."\n"; echo 'boolval of 3.5: '.( boolval( 3.5 )? 'true' : 'false')."\n"; echo 'boolval of -3.5: '.( boolval( -3.5 )? 'true' : 'false' )."\n"; echo 'boolval of 0.0: '.( boolval( 0.0 )? 'true' : 'false' )."\n"; echo 'boolval of "1": '.( boolval( "1" )? 'true' : 'false' )."\n"; echo 'boolval of "0": '.( boolval( "0" )? 'true' : 'false' )."\n"; echo 'boolval of "0.0": '.( boolval( "0.0" )? 'true' : 'false' )."\n"; echo 'boolval of "xyz": '.( boolval( "xyz" )? 'true' : 'false' )."\n"; echo 'boolval of "": '.( boolval( "" )? 'true' : 'false' )."\n"; echo 'boolval of [1, 5]: '.( boolval( [1, 5] )? 'true' : 'false' )."\n"; echo 'boolval of []: '.( boolval( [] )? 'true' : 'false' )."\n"; echo 'boolval of NULL: '.( boolval( NULL )? 'true' : 'false' )."\n"; ?> Output: boolval of 3: true boolval of -3 : true boolval of 0: false boolval of 3.5: true boolval of -3.5: true boolval of 0.0: false boolval of "1": true boolval of "0": false boolval of "0.0": true boolval of "xyz": true boolval of "": false boolval of [1, 5]: true boolval of []: false boolval of NULL: false Reference: http://https://www.php.net/manual/en/function.boolval.php Comment More infoAdvertise with us Next Article PHP abs() Function S sid4321 Follow Improve Article Tags : Web Technologies PHP Similar Reads PHP eval() Function PHP eval() function in PHP is an inbuilt function that evaluates a string as PHP code. Syntax: eval( $string ) Parameters: This function accepts a single parameter as shown in the above syntax and described below. $string: It must consist of a valid PHP code to be evaluated but should not contain op 2 min read PHP eval() Function PHP eval() function in PHP is an inbuilt function that evaluates a string as PHP code. Syntax: eval( $string ) Parameters: This function accepts a single parameter as shown in the above syntax and described below. $string: It must consist of a valid PHP code to be evaluated but should not contain op 2 min read PHP abs() Function The abs() function is an inbuilt function in PHP which is used to return the absolute (positive) value of a number. The abs() function in PHP is identical to what we call modulus in mathematics. The modulus or absolute value of a negative number is positive. Syntaxnumber abs( value )ParametersThe ab 1 min read PHP is_float() Function PHP is_float() is an inbuilt function in PHP. The is_float() function is used to find whether a variable is a float or not. Syntax: boolean is_float($variable_name) Parameter: This function contains a single parameter as shown in the above syntax and described below $variable_name: the variable we w 2 min read PHP is_float() Function PHP is_float() is an inbuilt function in PHP. The is_float() function is used to find whether a variable is a float or not. Syntax: boolean is_float($variable_name) Parameter: This function contains a single parameter as shown in the above syntax and described below $variable_name: the variable we w 2 min read PHP | is_callable() Function The is_callable() function is an inbuilt function in PHP which is used to verify the contents of a variable can be called as a function. It can check that a simple variable contains the name of a valid function, or that an array contains a properly encoded object and function name. Syntax: bool is_c 2 min read Like