Ec (2); & lt ;? FunctionfuncNum ($ str, $ num1, $ num2) number Regular Expression Test & nbsp ;{& nbsp; & nbsp; if ($ num1! And $ num2 !) {& Nbsp; return (preg_match (& quot; ^ [0-9] {& quot ;. $ num1. & quot;, & quot ;. $ num2 script ec (2); script
Function funcNum ($ str, $ num1 = '', $ num2 ='') // number regular expression test
{
If ($ num1! = ''And $ num2! = ''){
Return (preg_match ("/^ [0-9]
{". $ Num1.", ". $ num2."} $/", $ str ))? True: false;
} Else {
Return (preg_match ("/^ [0-9]/", $ str ))?
True: false;
}
}
Function funcCard ($ str )//
{
Return (preg_match ('/(^ ([d] {15} | [d] {18} | [d] {17} x)
$)/', $ Str ))? True: false;
}
If ($ _ POST)
{
If (funcNum ($ _ POST ['url'])
{
Echo 'is a number ';
}
Else if (funcCard ($ _ POST ['url'])
{
Exit ('Id card number ');
}
Else
{
Echo 'no number, not ID card No ';
}
}
?>
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
Php determines the regular expression of a number or ID card