View Full Version : integer
Uatec
Fri 13th Sep '02, 2:42pm
I have a form input that is going into a mysql DB. Is there a function that I could use to check that the contents of the variable is an integer?
Cheers.
Rob - Wellington College
Dan615
Fri 13th Sep '02, 4:47pm
if (intval($variable)) {
// blah blah blah;
}
Something like that...it can't be plain is_int because form data is automatically a string, I think...i could be wrong
kippesp
Sat 14th Sep '02, 12:01am
You'll get a false negative if the string is '0'.
To resolve that, change intval() to is_numeric(). PHP 4 required.
rylin
Sat 14th Sep '02, 1:42pm
or just use regular typecasting
(int)$variable
vBulletin® v3.8.0 Release Candidate 1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.