Get the IP address of a user

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ALEXKENT18
Forum Newbie
Posts: 1
Joined: Thu Jun 15, 2006 3:18 am

Get the IP address of a user

Post by ALEXKENT18 »

HI ALL,

I AM WONDERING WHETHER PHP CAN ACCESS THE IP ADDRESS OF THE USER OR NOT. ACTUALLY I AM THE NEW USER OF PHP.

IF THERE IS A WAY TO ACCESS IP ADDRESS WITH PHP, PLEASE KINDLY TEACH ME HOW.

WITH MANY THANKS,
ALEX
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Please DO NOT post in ALL UPPERCASE...it is seen as shouting!!

Your answer

Code: Select all

$_SERVER['REMOTE_ADDR'];
lettie
Forum Newbie
Posts: 15
Joined: Fri Jan 28, 2005 6:57 am

Post by lettie »

Define a variable to accept the remote server address then echo the variable:

Code: Select all

<?php
$ip_address = $_SERVER['REMOTE_ADDR'];
echo $ip_address;
?>
Post Reply