P hp provides very simple built-in function for checking where given value is numeric or not. I personally often check the value before entering it into database for exact data. Just copy below code and paste wherever you want and test it.
|
<?php $value1 = 'Ten'; $value2 = 10; //First Check if(is_numeric($value1)) { echo 'Value is Numeric'; } else { echo "Value is not Numeric"; } //Second Check if(is_numeric($value2)) { echo 'Value is Numeric'; } else { echo "Value is not Numeric"; } ?> |
Above code will check the value stored in variable and show us result. If the value is numeric it will show you message that value is numeric otherwise message will be Value is not numeric
Like this:
Like Loading...
Related
Good article