/*Determine whether the transmitted data is a number
Use regular expressions to determine whether the entered number is legal
Call: checknum (parameter 1, parameter 2)
*/
Copy code The code is as follows:
function checknum($id,$say)
{
$inid=$id;
if(! ereg("^(-{0,1}|+{0,1})[0-9]+(.{0,1}[0-9]+)$",$inid))
{
echo $say.", entrance: "."".$inid."";
exit;
} }
}
Call
Copy code The code is as follows:
$tid="111fff";
checknum($tid,"Illegal number")
?>
http://www.bkjia.com/PHPjc/317321.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317321.htmlTechArticle/* Determine whether the transmitted data is a number. Use regular expressions to determine whether the entered number is legal. Call: checknum(parameter 1, Parameter 2) */ Copy the code code as follows: functionchecknum($id,$say...