if string contains only numbers php code example
Example: how to check if PHP variable contains non-numbers?
if ( is_numeric($_POST['foo']) ) {
$foo = $_POST['foo'];
} else {
// Error
}
if ( is_numeric($_POST['foo']) ) {
$foo = $_POST['foo'];
} else {
// Error
}