Home > Backend Development > PHP Tutorial > 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
Release: 2016-07-21 15:59:27
Original
777 people have browsed it

/*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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template