PHP ip2long()関数
例
IPv4アドレスを長整数に変換します。
<?php
$ip = gethostbyname("www.w3schools.com");
$out = "The following URLs are
equivalent:<br>";
$out .= "https://www.w3schools.com/, https://" . $ip .
"/, and https://" . sprintf("%u", ip2long($ip)) . "/";
echo $out;
?>
定義と使用法
ip2long()関数は、IPv4アドレスを長整数に変換します。
構文
ip2long(address)
パラメータ値
Parameter | Description |
---|---|
address | Required. Specifies a standard IP address |
技術的な詳細
戻り値: | 長整数。失敗するとFALSE |
---|---|
PHPバージョン: | 4.0以降 |
PHP変更ログ: | PHP 5.5:このバージョンより前のWindowsでは、渡された値がIPv4アドレスでなくても、この関数が有効な数値を返す場合がありました。 PHP 5.2:PHP 5.5:このバージョンより前では、渡された値がIPv4アドレスでなくても、この関数は有効な数値を返す可能性がありました。 |
❮PHPネットワークリファレンス