PHP code example of dammynex / ngr-phone-validator
1. Go to this page and download the library: Download dammynex/ngr-phone-validator 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/ */
dammynex / ngr-phone-validator example snippets
use Brainex\Tools\PhoneValidator;
$phone = (new PhoneValidator())
//Phone number to validate
->setPhoneNumber('+2349061668519')
//We do not want exceptions
->setThrowExceptions(false)
//Do validation
->validate();
if($phone->isValid()) {
echo 'The phone number is valid';
}
use Brainex\Tools\PhoneValidator;
use Brainex\Exceptions\InvalidPhoneException;
try {
$phone = (new PhoneValidator())
->setPhoneNumber('+2349061668519')
->validate();
} catch(InvalidPhoneException $e) {
echo 'Invalid phone: ' . $e->getMessage();
}