문제

i want to convert this kind of address 0xC0A8071B to a numeric Ip Address (ex: 192.168.96.55)

How to do that in PHP?

도움이 되었습니까?

해결책

Use good old long2ip() here:

echo long2ip(0xC0A8071B);

Output:

192.168.7.27

A nice feature is that the parameter can be passed as numeric or string representation, this can be seen here: http://3v4l.org/P8TRB

The function ip2long() can be used to convert into the other direction, from an IP to a number. However, both functions will work with IPv4 addresses only.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top