PHP | long2ip() Function

PHP long2ip() Function

Hello folks! welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we are going to be studying about the PHP long2ip() Function.

The built-in PHP long2ip() function is used in converting long integer value into an IPv4 address.


Following below is the syntax to use this function -

string long2ip ( string $proper_address )

Parameter Details

Sr.NoParameters & Description


It contains Long integer value.

Return Value

This built-in function returns an internet IP address as a string on success, else false on failure.


Try out the following example below -

  $ip = "";
  $s32int = ip2long($ip);
  $us32str = sprintf("%u",$s32int);
  printf("%s %s",$us32str,long2ip(-(4294967296-$us32str)));


When the above code is executed, it will produce the following result below -


Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we are going to be discussing about the PHP openlog() Function.

Do feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Do follow us on our various social media handles available and also subscribe to our newsletter to get our tutorial posts delivered directly to your emails.

Thanks for reading and bye for now.