PHP ip2long() 函式
示例
將 IPv4 地址轉換為長整型
<?php
$ip = gethostbyname("www.w3schools.com");
$out = "以下 URL 是等效的:<br>";
$out .= "https://w3schools.tw/, https://" . $ip . "/, and https://" . sprintf("%u", ip2long($ip)) . "/";
echo $out;
?>
定義和用法
ip2long() 函式將 IPv4 地址轉換為長整型。
語法
ip2long(address)
引數值
引數 | 描述 |
---|---|
address | 必需。指定一個標準的 IP 地址 |
技術詳情
返回值 | 一個長整型。失敗時返回 FALSE |
---|---|
PHP 版本 | 4.0+ |
PHP 更新日誌 | PHP 5.5:在此版本之前,在 Windows 上,即使傳遞的值不是 IPv4 地址,此函式也可能返回有效數字。 PHP 5.2:PHP 5.5:在此版本之前,即使傳遞的值不是 IPv4 地址,此函式也可能返回有效數字。 |
❮ PHP 網路參考