我正在尝试验证某个输入,其中用户可以只输入整数值...否则将执行错误消息
$user_mcc = $_REQUEST['mobile_countrycode'];
if($user_mcc == ""){
is_numeric($_REQUEST['mobile_countrycode']);
}
if (!is_numeric($_REQUEST['mobile_countrycode'])){
echo '<script type="text/javascript">alert("Not a numeric value!\n\nMake sure that your country codes, area codes\nand mobile/fax/phone numbers are correct! \n"); return true;</script>';
echo '<script type="text/javascript">history.back();</script>';
die('' . mysql_error());
}
我已经尝试了很多功能,例如, ,empty等等is_null......但它没有用。== NULL== 'NULL
如果我在输入文本字段中输入一个字符串值,比如我输入... "Banana",则!is_numeric可以执行上面的函数,因为输入的值是FALSE而不是数值。
但是,每当我将输入字段留空时NULL,该!is_numeric函数仍然可以执行,就像它将一个NULL值识别为不是数值一样。!is_numeric如果输入值为.我该怎么做才能绕过功能NULL。谢谢你。
PS:我已经尝试过!is_int, !is_integerand ctype_digit,但结果相同,它不接受NULL值。