The code is as follows: |
Copy code |
Function funcphone ($ str) // call number regular expression test { Return (preg_match ("/^ (d {3}) | (d {3 }-))? (0d {2, 3}) | 0d {2, 3 }-)? [1-9] d {6, 8} $/", $ str ))? True: false; } |
// Usage
The code is as follows: |
Copy code |
If (funcphone ('2017-100 ')) { Echo 'correct phone number '; } Else { Echo 'Sorry, the phone number you entered is incorrect '; } |
The code is as follows: |
Copy code |
Function funcmtel ($ str) // phone number regular expression test { Return (preg_match ("/(? : 13d {1} | 15 [03689]) d {8} $/", $ str ))? True: false; } // Mobile phone number verification application If (funcmtel ('20140901 ')) { Echo 'The phone number you entered is correct '; } Else { Echo 'Enter the valid mobile phone number of China Mobile or the linked mobile phone number '; } |
// We separated the phone number verification from the phone number verification. Now we need to verify both the phone number and the phone number at the same time.
The code is as follows: |
Copy code |
If (functmtel ('000000') | funcphone ('2017-66661 ')) { Echo 'you can continue the operation! '; } Else { Echo 'only one phone number or mobile phone number is required '; } |
/*
This example provides an example to verify the mobile phone number and phone number (landline) separately.
This site original reprinted indicated from http://www.111cn.net/phper/php.html
*/