PHP code example of proficlos / phonenumber
1. Go to this page and download the library: Download proficlos/phonenumber library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
proficlos / phonenumber example snippets
use ProfiCloS\Tools\PhoneNumber;
// validation
PhoneNumber::isPhone('+420777666555'); // true
PhoneNumber::isPhone('777666555'); // true
PhoneNumber::isPhone('77766655'); // false
// parser
$phone = PhoneNumber::from('+420777666555');
$phone->setFormat( PhoneNumber::FORMAT_INTERNATIONAL );
echo $phone; // 00420777666555
$phone->setFormat( PhoneNumber::FORMAT_GSM );
echo $phone; // +420777666555
$phone->setFormat( PhoneNumber::FORMAT_CANONICAL );
echo $phone; // +420 777 666 555