Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top