Re: AW: AW: [PHP-DEV] FILTER_VALIDATE_INT and +0/-0

From: Date: Mon, 04 Feb 2013 17:28:00 +0000
Subject: Re: AW: AW: [PHP-DEV] FILTER_VALIDATE_INT and +0/-0
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-65640@lists.php.net to get a copy of this message
Both statements are wrong, since the purpose of the filter extension is to validate strings. I found this information in BR #52884 (see last comment). Maybe it should be added to the docs? It's nonsense to say, that FILTER_VALIDATE_INT must work like var_dump() since they are both serving different purposes. With this information I agree on your opinion. var_dump(filter_var('-0',FILTER_VALIDATE_INT)); // int(0) instead of the prior bool(false) var_dump('-0'); // string(2) "-0" var_dump(is_int('-0')); // bool(false)
var_dump does not attempt to convert a string into an integer when possible. FILTER_VALIDATE_INT does. This is much more analagous to FILTER_VALIDATE_INT IMO. $ php -r "echo (is_numeric('-0')) ? (int)'-0' : null;" 0 I am not intimately familiar with the internals of filter, but I replaced code in userland like this with filter calls. Brian Moon

« previous php.internals (#65640) next »