PHP code example of flying-bird / phone-location
1. Go to this page and download the library: Download flying-bird/phone-location 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/ */
flying-bird / phone-location example snippets
flyingBird\PhoneLocation\PhoneLocation;
// 方式一:不传参数,自动使用包内置的 phone.dat(推荐)
$phone = new PhoneLocation();
// 方式二:传入自定义路径,使用自己的数据文件
// $phone = new PhoneLocation('/path/to/your/phone.dat');
$result = $phone->find('18888888888');
if ($result) {
echo "省份:{$result['province']}\n";
echo "城市:{$result['city']}\n";
echo "运营商:{$result['operator']}\n";
}