is_numeric is used to find a variable is number or string
Example:
index.php
<?php
//numeric check
if (is_numeric (8))
{
echo "Yes";
}
else {
echo "No";
}
?>
8 is a number,then should result is "Yes"
<?php
//No-numeric check
if (is_numeric ("test"))
{
echo "Yes";
}
else
{
echo "No";
}
?>
Test is not a number,then should result is "No"
Example:
index.php
<?php
//numeric check
if (is_numeric (8))
{
echo "Yes";
}
else {
echo "No";
}
?>
8 is a number,then should result is "Yes"
<?php
//No-numeric check
if (is_numeric ("test"))
{
echo "Yes";
}
else
{
echo "No";
}
?>
Test is not a number,then should result is "No"
No comments:
Post a Comment