In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "how to use php to judge whether it is a mobile phone number or not". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The method of php judging whether it is a mobile phone number: 1, using the regular expression "$g =" / ^ 1 [34578]\ d {9} $/ ";" judging the mobile phone number; 2, judging by "if (preg_match (" / ^ 1 [34578]\ d {9} $/ ", $mobile)) {...}".
This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer
The method of judging Mobile phone number regularly by php
Introduction:
Php uses regular expressions to determine how mobile phone numbers are written: match all the mobile phone numbers from the article and preg_match_all (). If you want to check whether the mobile phone number entered by the user is correct, check it like this: preg_match ().
When using regular matching mobile phone numbers, let's first analyze the rules of mobile phone numbers:
1. The mobile phone number is usually 11 digits.
two。 It often starts with 1.
3. The second number is usually the number 34578, and the mobile phone number in section 170 goes on sale on May 5, 2014, so there is an extra 7.
Php uses regular expressions to determine how to write a mobile phone number:
G = "/ ^ 1 [34578]\ d {9} $/"
The / / "^" symbol must start with 1; "[]" means that the second number must be a number in square brackets; and\ d means any number in square brackets, followed by {9} that the length is 9 digits; the following $indicates the end; the regular expressions at the beginning and end must be placed in the middle, and some may be followed by a pattern.
Match all the mobile phone numbers from the article and write like this:
$str = 'Old Bar blogger's mobile phone is 18912345678 (/ ^ 1 [34578]\ d {9} $/ ", $str, $mobiles); / / var_dump ($mobiles)
If you want to check whether the mobile phone number entered by the user is correct, check it like this:
If (preg_match ("/ ^ 1 [34578]\ d {9} $/", $mobile)) {/ / there is an infinite imagination} "how to use php to determine whether it is a mobile phone number". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 287
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.