php example code : is_numeric function in php - number checker
is-numeric-php-example.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>php example code : is_numeric function in php - number checker</title>
</head>
<body>
<h3>php example code : is_numeric function in php - number checker</h3>
<?php
/*
----------------------------------------------------------------------------
let us make a number and test it wheather it is a number or not
by using php is_numeric function
----------------------------------------------------------------------------
*/
$myNumber = true;
$numberFlag = is_numeric($myNumber);
if($numberFlag == true)
{
echo 'it is a number';
}
else
{
echo 'it is not a number';
}
echo "<br><br>";
/*
----------------------------------------------------------------------------
let us make a non number and test it wheather it is a number or not
by using php is_numeric function
----------------------------------------------------------------------------
*/
$myNumber = 'abc';
$numberFlag = is_numeric($myNumber);
if($numberFlag == true)
{
echo 'it is a number';
}
else
{
echo "<h4 style='color:red;'>it is not a number</h4>"; }
?>
</body>
</html>

No comments:
Post a Comment
leave your comments here..