php函数long2ip与ip2long()

long2ip — Converts an long integer address into a string in (IPv4) Internet standard dotted format

string long2ip ( string $proper_address )

The function long2ip() generates an Internet address in dotted format (i.e.: aaa.bbb.ccc.ddd) from the long integer representation

意思就是:用于将一个数字格式的IPv4地址转换成字符串格式(192.168.0.1)

而ip2long恰好与之相反

Converts an long integer address into a string in (IPv4) Internet standard dotted format

eg:

<?php
$ip = gethostbyname('www.csdn.net');

        $num_ip =  ip2long($ip);
echo $num_ip,'<br/>';
echo long2ip($num_ip);

?>

结果:

php函数long2ip与ip2long()

上一篇:Vue CLI 3+tinymce 5富文本编辑器整合


下一篇:python的selenium