PHP boolval() Function
PHP boolval() Function
The boolval() function in PHP is used to give the Boolean value for a given variable.
Syntax
boolval ( mixed $var )
Parameter
var(required)- This parameter represents the value that is converted to a boolean. It can be a string type, integer type etc.
Return
This function returns the boolean value for the parameter var. The Boolean value is evaluated based on the following conditions:
- if $var is evaluated to boolean true it will return TRUE.
- if $var is evaluated to boolean false it will return FALSE.
Example 1
Output
0.0 will return: false 12 will return: true 0 will return: false
Example 2
Output
4.2 will return : true "" will return : false
Example 3
Output
"PHP": true "10": true "11": true
Example 4
Output
[11, 12]: true [] : false stdClass: true