On Thu, 2003-10-23 at 12:41, John W. Holmes wrote:
> Greg Beaver wrote:
>
> > http://www.php.net/is_numeric
> >
> > is the function you are looking for. No need for fancy regexps.
>
> The OP is looking for an integer, but is_numeric() will return true for
> float values and also for numbers in scientific notation. So "12.3" and
> "12E3" will be TRUE.
>
> The original $number != intval($number) should work for detecting bad
> input.
This doesn't work John, because the the != will convert the $number to
an intval for the comparison; however, after reflecting on your code and
the style you used.. hte following will work :)
$foo = '123fooo';
if( trim( $foo ) != ''.intval( $foo ) )
{
echo "Not same beast!\n";
}
else
{
echo "Same beast!\n";
}
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php