Current Location: Home> Function Categories> boolval

boolval

Get the boolean value of a variable
Name:boolval
Category:Variable processing
Programming Language:php
One-line Description:Returns the Boolean value of the variable.

Definition and usage

boolval() function returns the Boolean value of the variable.

Example

Returns boolean values ​​for different variables:

 <?php
echo "0: " . ( boolval ( 0 ) ? 'true' : 'false' ) . "<br>" ;
echo "4: " . ( boolval ( 42 ) ? 'true' : 'false' ) . "<br>" ;
echo '"": ' . ( boolval ( "" ) ? 'true' : 'false' ) . "<br>" ;
echo '"Hello": ' . ( boolval ( "Hello" ) ? 'true' : 'false' ) . "<br>" ;
echo '"0": ' . ( boolval ( "0" ) ? 'true' : 'false' ) . "<br>" ;
echo "[3, 5]: " . ( boolval ( [ 3 , 5 ] ) ? 'true' : 'false' ) . "<br>" ;
echo "[]: " . ( boolval ( [ ] ) ? 'true' : 'false' ) . "<br>" ;
?>

Try it yourself

grammar

 boolval ( variable ) ;
parameter describe
variable Required. Specifies the variable to check. Must be a scalar type.
Similar Functions
Popular Articles