Library code snippets
Determine if a variable is numeric
By James Crowley, published on 28 Sep 2001
There are a number of ways to determine if a variable in PHP
is numeric. If you have PHP 4, you can use the is_numeric function:if (is_numeric($thefield)==false) {
echo "\$thefield is not a number";
}
If you have PHP 3, then you can use the following function
function is_numeric($value) {
if (((int) $value)== $value) {
return true;
} else {
return false;
}
}
Related articles
Related discussion
-
Sending Multiple ListBox Selection to PHP
by cnrez (6 replies)
-
A particular gallery image
by margy80 (0 replies)
-
code highlighting using jquery
by pjm (1 replies)
-
PHP London July Meetup
by Dalton (0 replies)
-
How to prevent spam
by boopathi_php (0 replies)
Related podcasts
-
EarthClassMail.com - Moving from LAMP to .NET 3.5
Scott chats with Matt Davis, architect at EarthClassMail.com, about their move from a LAMP stack (Linux/Apache/mysql/PHP) to .NET 3.5. What's working, what's not, and what kinds of issues are they running into as their architect their solution.
Events coming up
-
Jul
18
WordCamp UK 2009
Cardiff, United Kingdom
This is the second WordCamp UK - an informal annual gathering of WordPress publishers, designers and developers based in the United Kingdom.
This thread is for discussions of Determine if a variable is numeric.