Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 19,564 times

Related Categories

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;
  }
}

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments