For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > May 2005 > isNumber function?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author isNumber function?
laredotornado@zipmail.com

2005-05-29, 3:56 am

Hello, I'm using PHP 4 and I was wondering if there was a function, or
an easy way to check if a variable is a number. THe "intval" function
doesn't work very well for me because if the variable is "abc" or "0",
the same value is returned. I would prefer a function that tells me
"abc" is not a number and "0" is a number.

Thanks, - Dave

Nicholas Sherlock

2005-05-29, 3:56 am

laredotornado@zipmail.com wrote:
> Hello, I'm using PHP 4 and I was wondering if there was a function, or
> an easy way to check if a variable is a number. THe "intval" function
> doesn't work very well for me because if the variable is "abc" or "0",
> the same value is returned. I would prefer a function that tells me
> "abc" is not a number and "0" is a number.


Would IsNumeric() fit the bill?

Cheers,
Nicholas Sherlock
Philip Olson

2005-05-29, 3:55 pm

Just in case you didn't find it yet... it's is_numeric() ;-)

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com