PHP code example of joql / zx-ip-address
1. Go to this page and download the library: Download joql/zx-ip-address 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/ */
joql / zx-ip-address example snippets
$result = \Ritaswc\ZxIPAddress\IPTool::query('8.8.8.8');
/*
$result = [
"start" => "8.8.8.8"
"end" => "8.8.8.8"
"addr" => array:2 [
0 => "美国"
1 => "加利福尼亚州圣克拉拉县山景市谷歌公司DNS服务器"
]
"disp" => "美国 加利福尼亚州圣克拉拉县山景市谷歌公司DNS服务器"
]
*/
$result = \Ritaswc\ZxIPAddress\IPTool::query('240e:e9:8819:0:3::3f9');
/*
$result = [
"start" => "240e:e9:8800::"
"end" => "240e:e9:8fff:ffff::"
"addr" => array:2 [
0 => "中国江苏省苏州市"
1 => "中国电信IDC"
]
"disp" => "中国江苏省苏州市 中国电信IDC"
]
*/
$valid = \Ritaswc\ZxIPAddress\IPv4Tool::isValidAddress('114.114.114.114');
/*
$valid = true;
*/
$valid = \Ritaswc\ZxIPAddress\IPv6Tool::isValidAddress('240e:e9:8819:0:3::3f9');
/*
$valid = true;
*/