View Full Version : how to send sms using php script ?
Prateek.sem
04-29-2010, 06:51 AM
i am looking for a phone number verification using php ?
james438
04-29-2010, 07:05 AM
Forgive me if I am wrong, but this sounds like a homework assignment.
I will say that you will need to use PCRE (Perl Compatible Regular Expressions) for this. In particular you need to use preg_match. I assume that what you are talking about is data submitted via form and you want to check to see if it is a valid phone number as opposed to something made up, similar to detecting whether the email a user submits is a valid email. You probably also want to be sure that the phone number is U.S. based or other.
djr33
04-29-2010, 09:01 PM
It's fairly easy to do a few ways. I'm sure there's an answer out there on google. Using regex [regular expressions] (described above) is the shortest way to go, or you could just split the phone number at various parts. For example, the area code should be between 100 and 999, so just do that using basic math.
The main problem with this is dealing with lots of varied user input:
###-###-#### or (###) ###-#### or ##########, etc.
One way to do this is to pre-process the values: remove everything that is not a number.
But what about international numbers? What about numbers without an area code? Not allowed? Treated differently?
If you still remove everything that is not a number then you can check the length and go from there: if it's 7 numbers it's a local number; if it's 10 it's got the area code; if there's more, then you get an international number.
But there are also problems with adding the "1" before something like "1-800" vs "800".
Again, I'd just look on google....
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.