2017 © Pedro Peláez
 

library libphonenumber-for-php

Clone of Phone number handling library by Davide Mendolia

image

practo/libphonenumber-for-php

Clone of Phone number handling library by Davide Mendolia

  • Wednesday, January 29, 2014
  • by justjkk
  • Repository
  • 0 Watchers
  • 0 Stars
  • 27,153 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 1 % Grown

The README.md

Project not maintained anymore. See https://github.com/giggsey/libphonenumber-for-php

Travis Build, (*1)

What is it?

PHP library for parsing, formatting, storing and validating international phone numbers., (*2)

Highlights of functionality

  • Parsing/formatting/validating phone numbers for all countries/regions of the world.
  • getNumberType - gets the type of the number based on the number itself; able to distinguish Fixed-line, Mobile, Toll-free, Premium Rate, Shared Cost, VoIP and Personal Numbers (whenever feasible).
  • isNumberMatch - gets a confidence level on whether two numbers could be the same.
  • getExampleNumber/getExampleNumberByType - provides valid example numbers for all countries/regions, with the option of specifying which type of example phone number is needed.
  • isValidNumber - full validation of a phone number for a region using length and prefix information.

Quick Examples

Let's say you have a string representing a phone number from Switzerland. This is how you parse/normalize it into a PhoneNumber object:, (*3)

$swissNumberStr = "044 668 18 00";
$phoneUtil = PhoneNumberUtil::getInstance();
try {
    $swissNumberProto = $phoneUtil->parse($swissNumberStr, "CH");
    var_dump($swissNumberProto);
} catch (NumberParseException $e) {
    echo $e;
}

At this point, swissNumberProto contains:, (*4)

object(libphonenumber\PhoneNumber)#221 (5) {
  ["countryCode":"libphonenumber\PhoneNumber":private]=>
  int(41)
  ["nationalNumber":"libphonenumber\PhoneNumber":private]=>
  int(446681800)
  ["extension":"libphonenumber\PhoneNumber":private]=>
  NULL
  ["italianLeadingZero":"libphonenumber\PhoneNumber":private]=>
  NULL
  ["rawInput":"libphonenumber\PhoneNumber":private]=>
  NULL
}

Now let us validate whether the number is valid:, (*5)

$isValid = $phoneUtil->isValidNumber($swissNumberProto);//return true
var_dump($isValid);

There are a few formats supported by the formatting method, as illustrated below:, (*6)

// Produces "+41446681800"
echo $phoneUtil->format($swissNumberProto, PhoneNumberFormat::E164) . PHP_EOL;

The Versions

29/01 2014

dev-master

9999999-dev https://github.com/practo/libphonenumber-for-php

Clone of Phone number handling library by Davide Mendolia

  Sources   Download

Apache-2.0

validation mobile phonenumber libphonenumber

31/10 2013

5.8.8

5.8.8.0 https://github.com/practo/libphonenumber-for-php

Clone of Phone number handling library by Davide Mendolia

  Sources   Download

Apache-2.0

validation mobile phonenumber libphonenumber

06/03 2013

dev-mobilepatternupdate_090313

dev-mobilepatternupdate_090313 https://github.com/practo/libphonenumber-for-php

Clone of Phone number handling library by Davide Mendolia

  Sources   Download

Apache-2.0

validation mobile phonenumber libphonenumber

22/10 2012

dev-mobilepatternupdate_221012

dev-mobilepatternupdate_221012 https://github.com/practo/libphonenumber-for-php

Clone of Phone number handling library by Davide Mendolia

  Sources   Download

Apache-2.0

validation mobile phonenumber libphonenumber

22/09 2012

dev-mobilepatternupdate_220612

dev-mobilepatternupdate_220612 https://github.com/practo/libphonenumber-for-php

Clone of Phone number handling library by Davide Mendolia

  Sources   Download

Apache-2.0

validation mobile phonenumber libphonenumber