Library code snippets
Determine if a variable is numeric
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
-
Create this kind of website
by maidentv (1 replies)
-
PHP London July Meetup
by webdeveloperit (1 replies)
-
Binary Studio | software development outsourcing Ukraine
by shane124 (4 replies)
-
SOFTWARE PHP WORK
by synctel (0 replies)
-
London PHP / MySQL Superstar needed!
by gatewaytechnolabs (1 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
-
Dec
3
The Auckland PHP December meetup
Auckland, New Zealand
Topic: Magento E-Commerce platform Speaker: Robert Popovic, LERO9, Robert is the Technical Director and co-founder of LERO9. Robert attended the Electrotechnical Faculty at The University of Belgrade where he graduated with a Masters in Computer Science and Information Technology. Robert has worked exclusively in the field of web and software development throughout his career.
This thread is for discussions of Determine if a variable is numeric.