$var=5;
if(is_int($var)){
echo " this is an integer ";// This is the output
}else{
echo " this is not an integer ";
}
Example : <?php
$var=5;
echo is_int($var); // Output 1
echo "<br>";
$var='5';
echo is_int($var); // No Output
echo "<br>";
$var=5.8;
echo is_int($var); // No output (for Float)
echo "<br>";
$var=+5;
echo is_int($var); // Output 1
echo "<br>";
$var=-5;
echo is_int($var); // Output 1
echo "<br>";
$var='a123';
echo is_int($var); // No output
echo "<br>";
?>
$var="123";
if(is_int($var)){
echo " this is an integer ";
}else{
echo " this is not an integer ";}
Above code will say this is not an integer$var=$_POST['t1'];
if(is_int($var)){
echo " this is an integer ";
}else{
echo " this is not an integer ";
}
We can create an form to post data to the above code like this
<form method=post action=is_int1.php>
<input type=text name=t1>
<input type=submit value=submit>
In the above form if we post an integer then also is_int will return false.
gen | 13-07-2012 |
how about is not numeric??? |