What is the best way of checking if input is numeric?
Those kind of numbers should not be valid. Only numbers like: 123, 012 (12), positive numbers should be valid.
This is mye current code:
$num = (int) $val;
if (
preg_match('/^d+$/', $num)
&&
strval(intval($num)) == strval($num)
)
{
return true;
}
else
{
return false;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…