The function Michael Smith published doesn't do the work as it should.
To check if a variable is boolean is one thing, to evaluate if the value of a variable represents a boolean condition (true or false) is another.
Here a simple function that checks the status of the received variable in regards to boolean equivalencies (case insensitive).
<?php
function is_enabled($variable)
{
if (!isset($variable)) return null;
return filter_var($variable, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
}
?>
Of course, it is a simplistic approach, but for the majority of cases it will do the job right.
And, just to put thing in the right perspective, here's a real function that does what Phill disclosed:
<?php
function to_bool($variable)
{
return (bool)$variable;
}
?>
I hope it helps someone. Happy coding.