geoip_netspeedcell_by_name
(PECL geoip >= 1.1.0)
geoip_netspeedcell_by_name — 獲取網路連線速度
說明
geoip_netspeedcell_by_name(string
$hostname
): stringgeoip_netspeedcell_by_name() 函式將會返回主機或者 IP 地址對應的網路連線型別和速度。
該函式只有在 GeoIP 1.4.8 版本以上才能使用。
目前,該函式只對購買了商業 GeoIP NetSpeedCell 版本的使用者可用,否則將會拋出一個警告!
返回值為字串,結果集如下:
- Cable/DSL
- Dialup
- Cellular
- Corporate
參數
-
hostname
-
主機名或者 IP 地址。
返回值
成功,返回連線速度,未找到相關資訊則返回 false
。
範例
示例 #1 一個 geoip_netspeedcell_by_name() 使用範例:
以下程式碼將會輸出 example.com 主機的連線速度。
<?php
$netspeed = geoip_netspeedcell_by_name('www.example.com');
if ($netspeed) {
echo 'The connection type is: '. $netspeed;
}
?>
以上例程會輸出:
The connection type is: Corporate