View Full Version : Need to check that $var is a number or decimal place *PHP*

05-11-2006, 02:11 PM
Anyone know what command it is to check that a Var is a number or decimal number? I have found is_numeric() but this allows letters (hex numbers) and + and - signs.

05-11-2006, 02:21 PM

is_float ($var);

this looks for a floating point numeric and returns a boolean (true or false)

05-11-2006, 02:27 PM
Thanks mate...

05-12-2006, 10:59 AM
umm, had to go with is_numeric in the end is_float didnt seem to work too well - well not atall actually. I think is_numeric will only TRUE anything that is a HEX number etc... What are the chances of someone typing in a hex number... pretty slim I think, and they will only get an SQL error anyway, or I might make a custom error page with a flash movie on it so they get a virtual slap.