Home >Backend Development >PHP Tutorial >fun factory has a Function that detects whether the transmitted parameters are numbers.
/*Judge 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 The code is as follows:
function checknum( $id,$say)
{
$inid=$id;
if(!ereg("^(-{0,1}|+{0,1})[0-9]+(.{0,1 }[0-9]+)$",$inid))
exit;
} }
}
Call
Copy code The code is as follows:$tid="111fff";
checknum($tid,"Illegal number")
?>
The above introduces the function of fun factory to detect whether the transmitted parameters are numbers, including the content of fun factory. I hope it will be helpful to friends who are interested in PHP tutorials.