Re: Re: test if $int is integer

From: Date: Tue, 29 Jun 2004 22:12:22 +0000
Subject: Re: Re: test if $int is integer
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-189240@lists.php.net to get a copy of this message
> Vlad Georgescu wrote: > >> how can test if var $int is integer ? > > In the manual: > > http://www.php.net/is_int > > Another one which might be helpful: > > http://www.php.net/is_numeric > > > Hope this helps, > > Torben > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > 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>

« previous php.general (#189240) next »