PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Dave Smith   Free Phone Number Verification in PHP   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example Usage
Class: Free Phone Number Verification in PHP
Verify phone numbers of many countries
Author: By
Last change: Updated to ver 1.0
Date: 5 years ago
Size: 1,659 bytes
 

Contents

Class file image Download
<?php
/*
verify phone number
numverify ver 1.0
*/

//include the class
include('numverify.class.php');

//instantiate the class
$numVerify = new numVerify();

//phone number to check
//API can accept all numeric numbers or number with special characters like (555) 5555-55555
$phoneNumber = 'ADD_A_PHONE_NUMBER_HERE';

//logic to determine if number is valid, invalid or an error occured
if( $numVerify->isValid($phoneNumber,'US',false,true) === false ){

    if( !empty(
$numVerify->errorCode) ){
       
//an error occured

       
echo 'The request returned an error -> ['.$numVerify->errorCode.'] '.$numVerify->errorText;

    }else{
       
//number is not valid

       
echo 'The phone number '.$phoneNumber.' is NOT valid';

    }

}else{
   
//number is valid

   
echo 'The phone number '.$phoneNumber.' is valid';

}

//display the response object
echo '<hr>';
echo
'<pre>';
var_dump($numVerify->response);
echo
'</pre>';

/*
a validation request will return the following object properties

valid - true or false
number - clean format of phone number provided
local_format - local/national format of phone number
international_format - international format of phone number with calling code
country_code - 2-letter country code
country_name - full country name
location - local location if available (country, state, etc)
carrier - name of phones carrier, service provider
line_type - line type
    mobile = mobile phone
    landline = land line
    special_services = police, fire, etc...
    toll_free = toll free number
    premium_rate = paid services number like hotlines

*/
?>