Yeah, 4 will pass the is_int() test, '4' won't.
I prefere just to use if(ctype_digit($foo)){ ... }

On Tue, 29 Jun 2004 15:12:22 -0700 (PDT), Matthew Sims
<[EMAIL PROTECTED]> wrote:

> I recently purchased George Schlossnagle's Advanced PHP Programming and on
> page 85 in the Error Handling chapter, he made a reference about the
> is_int function.
> 
> In the above function example he had:
> if (!preg_match('/^\d+$/',$n) || $n < 0) {....
> 
> In which he mentions:
> It might be strange to choose to evaluate whether $n is an integer by
> using a regular expression instead of the is_int function. The is_int
> function, however, does not do what you want. It only evaluates whether $n
> has been typed as a string or as an integer, not whether the value of $n
> is an integer.
> 
> Can anyone comment on this?
> 
> --Matthew Sims
> --<http://killermookie.org>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to