PHP boolval() Function
❮ PHP Variable Handling Reference
Example
Return the boolean value of 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 »
Definition and Usage
The boolval() function returns the boolean value of a variable.
Syntax
boolval(variable);
Parameter Values
Parameter | Description |
---|---|
variable | Required. Specifies the variable to check. Must be a scalar type |
Technical Details
Return Value: | The boolean value of the variable |
---|---|
Return Type: | Boolean |
PHP Version: | 5.5+ |
❮ PHP Variable Handling Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.