PHP 5.4 filter_var() FILTER_VALIDATE_BOOLEAN bug? Or change from 5.3?

625 Views Asked by At

I think I found a bug in PHP 5.4.23, but I suppose it is possible expected behavior as well. I am expecting a filter_var call to return null, but it isn't. Is this code correct, and is my assumption that this is a bug and not a recent change correct as well?

Test code

var_dump(filter_var(null, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE));

PHP 5.3.28 Results:

NULL

PHP 5.4.23 Results:

bool(false)
1

There are 1 best solutions below

1
On

Usually when a function returns NULL it succeded. false is returned when it failed (by convention).