inet_pton 将点分文本的IP地址转换为二进制网络字节序的IP地址
<?php $in_addr = inet_pton('127.0.0.1'); $in6_addr = inet_pton('::1'); ?>
inet_ntop 将二进制网络字节序的IP地址转换为点分文本的IP地址
<?php $packed = chr(127) . chr(0) . chr(0) . chr(1); $expanded = inet_ntop($packed); /* Outputs: 127.0.0.1 */ echo $expanded; $packed = str_repeat(chr(0), 15) . chr(1); $expanded = inet_ntop($packed); /* Outputs: ::1 */ echo $expanded; ?>
最新评论: