PHP - ip2long 函式



語法

int ip2long ( string $ip_address )

定義和用法

它用於將 IPv4 地址轉換為長整數。

返回值

它返回長整數,或者顯示 IP 地址無效的訊息。

引數

序號 引數及描述
1

ip_address

包含 IP 地址。

示例

嘗試以下示例

<?php
   $ip = gethostbyname('www.tutorialspoint.com');
   $out = "The following URLs are equivalent:
   \n";
   
   $out .= 'https://tutorialspoint.tw/, http://' . $ip . '/, 
      and http://' . sprintf("%u", ip2long($ip)) . "/
   \n";
   
   echo $out;
?>

這將產生以下結果:

The following URLs are equivalent:
https://tutorialspoint.tw/, http://72.21.91.8/, and http://1209359112/
php_function_reference.htm
廣告