I\'m getting a string from a $_GET and I want to test if it could be a boolean, before I use it for a part of a mysql query. Is there a better way of doing it than:
If you use the flag FILTER_NULL_ON_FAILURE, filter_var() will work nicely:
FILTER_NULL_ON_FAILURE
filter_var()
function CheckBool($Value) { return null !== filter_var($Value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); }