TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
How to get IP address using PHP
Bhushan Singh
Oct 30
2014
Code
1.6
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
index.zip
<?php
function
getIpAddress()
{
if
(!
empty
empty
(
$_SERVER
[
'HTTP_CLIENT_IP'
]))
{
$ip
=
$_SERVER
[
'HTTP_CLIENT_IP'
];
}
elseif
(!
empty
empty
(
$_SERVER
[
'HTTP_X_FORWARDED_FOR'
]))
//to check ip is pass from proxy
{
$ip
=
$_SERVER
[
'HTTP_X_FORWARDED_FOR'
];
}
else
{
$ip
=
$_SERVER
[
'REMOTE_ADDR'
];
}
return
$ip
;
}
echo
getIpAddress();
?>
get ip address using php
ip address
get ip address using php