You can use boolval(), but it doesn’t produce correct results for “True” and “False” values.

This is the better method:

if (filter_var($MyVariable, FILTER_VALIDATE_BOOLEAN))
{
 //Value is true
}

if (!filter_var($MyVariable, FILTER_VALIDATE_BOOLEAN))
{
 //Value is false
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *