RE: [PHP] FILTER_VALIDATE_INT - newbie question
| From: | MEM | Date: | Wed, 07 Oct 2009 11:03:24 +0000 |
| Subject: | RE: [PHP] FILTER_VALIDATE_INT - newbie question | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-298720@lists.php.net to get a copy of this message | ||
> Well, it was only a guess, but if you look at the integer limit on 32-bit systems, you'll
> see that the upper limit > for numbers is 2147483647 (or 2^31-1) which would explain maybe your
> upper limit problem.
>
> Also, I think you're getting confused over the zero with exactly what you are asking PHP
> to do. filter_var() returns > true if the filter matches. If the 0 match is returned as a false,
> then filter_var() will return false. You're then > inverting that with a !, all of which is
> inside an if() statement. Essentially this would mean that if the filter > returns false then the
> instructions inside of the if statement are carried out.
I always thought that that was a limit of the number of digits an integer value could have, and not
the actually int value... I guess I was wrong. :s
You are right, I've tested with:
2147483647
it worked.
I've tested with:
2147483648
It displays the error.
"you're getting confused over the zero with exactly what you are asking PHP to do"
Absolutely... :(
If I put 0 filter_var() will return false.
If I put 0342352 filter_var() will also return false.
Could we say that: if it is indeed the fact, that filter_var() returns false when it finds a 0 at
the beginning of a given number...
"then the instructions inside of the if statement are carried out."
And here may be the reason for displaying the error message when we have the 0 leading a number.
And my point was exactly here
"If the 0 match is returned as a false"
Why should filter_var() do something like this? Should the filter_var() interpretate 0 as a number
without boolean semantic value?
Please be patient...
Regards,
Márcio