English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP basic tutorial

PHP advanced tutorial

PHP & MySQL

PHP reference manual

PHP long2Usage and examples of ip() function

PHP HTTP  reference manual

long2The ip() function converts a long integer to a string format with dots in the Internet standard format address (IPV4)。

Syntax

string long2ip ( string $proper_address )

Definition and usage

It is used to convert the long integer value to Ipv4Address.

Return value

Returns the IP address in string form

Parameter

Serial numberParameters and descriptions
1

proper_address

It contains the long integer value

Online example

Try the following example

<?php
  $ip = "49.204.34.96";
  $s32int = ip2long($ip);
  $us32str = sprintf("眻,$s32int);
  
  printf("%s %s",$us32str,long2ip(-(4294967296-$us32str)));
?>

The above code converts the IP address to a long integer and converts the long integer to an IP address

835461728 49.204.34.96

PHP HTTP  reference manual