inet_pton() - php 网络函数
inet_pton()
(PHP 5 >= 5.1.0, PHP 7)
Converts a human readable IP address to its packed in_addr representation
说明
inet_pton(string $address): stringThis function converts a human readable IPv4 or IPv6 address (if PHP was built with IPv6 support enabled) into an address family appropriate 32bit or 128bit binary structure.
参数
$addressA human readable IPv4 or IPv6 address.
返回值
Returns thein_addrrepresentation of the given$address,orFALSE
if a syntactically invalid$addressis given (for example, an IPv4 address without dots or an IPv6 address without colons).
范例
Example #1inet_pton()Example
更新日志
版本 | 说明 |
---|---|
5.3.0 | This function is now available on Windows platforms. |
参见
ip2long()
将 IPV4 的字符串互联网协议转换成长整型数字long2ip()
将长整型转化为字符串形式带点的互联网标准格式地址(IPV4)inet_ntop()
Converts a packed internet address to a human readable representation
Be careful, address with leading 0 return false. Example :
It is possible to verify if PHP was compiled with --disable-ipv6 option by AF_INET6 constant.
If the input string is not a readable IP address, inet_pton() generates an E_WARNING and returns FALSE. The same is true for inet_ntop(). Also, inet_pton() does not recognize netmask notation (e.g: "1.2.3.4/24" or "1:2::3:4/64") in the input string. This differs from how some database systems (like postgreSQL) support IP address types, so if you need that sort of functionality when processing IP addresses in PHP you'll have to write it in yourself. A rough example:
鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com
图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!