Yii 1.1: libphonenumber

One simple libphonenumber php class for Yii framework
8 followers

This is just a wrapper class of libphonenumber by Davide Mendolia's extension libphonenumber-for-PHP

Requirements

...requirements of using this extension (e.g. Yii 1.1 or above)...

Installation

  • Download and extract extension files to the directory protected/vendors

Usage

Wherever you want to validate the phone number,use the following codes

Yii::setPathOfAlias('libphonenumber',Yii::getPathOfAlias('application.vendors.libphonenumber'));
 
$phonenumber=new libphonenumber\LibPhone($your_phone_number);
 
/**
  * Checking the number is valid or not  
  *
  * @return boolean
  */
$phonenumber->validate();   //return true if valid
 
//to convert to international format
$phonenumber->toInternational();
 
//to get national format
$phonenumber->toNational();
 
//to get E164 format
$phonenumber->toE164();
 
/*to get out of country calling number format
 *need to pass the region value
 */
$phonenumber->toOutOfCountryCallingNumber($region);

Resources

Total 1 comment

#12827 report it
sirin k at 2013/04/14 11:49am
Nice

Nice one.

Leave a comment

Please to leave your comment.

Create extension