Home  >  Article  >  Backend Development  >  Made a Function_PHP tutorial to detect whether the transmitted parameter is a number

Made a Function_PHP tutorial to detect whether the transmitted parameter is a number

WBOY
WBOYOriginal
2016-07-21 15:59:27748browse

/*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")
?>

www.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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn