PHP - How to display IP address of a visitor?

Simple method



Displaying IP in a graphic mode

Show IP Display visitor's IP Address in a graphic with this simple php code.
Consider that:
Your IP Address
Create a new page, copy the text below and save it as image.php (or whatever you wish)
$img_number = imagecreate(275,25);
$backcolor = imagecolorallocate($img_number,102,102,153);
$textcolor = imagecolorallocate($img_number,255,255,255);

$number = " Your IP is $_SERVER[REMOTE_ADDR]";


header("Content-type: image/jpeg");

All you'll need to display on other pages is the code below.

<img src="" border="1">
Published by hyts78. Latest update on December 19, 2009 at 01:38 AM by jak58.
This document, titled "PHP - How to display IP address of a visitor?," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (
Mktime() - Timestamp yesterday, last month, etc.).
Creating a forum with phpBB