The FILTER_VALIDATE_BOOLEAN constant validates value as a boolean option.
Return
The FILTER_VALIDATE_BOOLEAN constant returns TRUE for "1", "true", "on" and "yes". It returns FALSE for "0", "false", "off" and "no" otherwise, NULL.
Example
<?php $var="on"; var_dump(filter_var($var, FILTER_VALIDATE_BOOLEAN)); ?>
Output
The following is the output.
bool(true)
Example
Let us see another example.
<?php $var="off"; var_dump(filter_var($var, FILTER_VALIDATE_BOOLEAN)); ?>
Output
Here is the output.
bool(false)