display ip address

2 posts Page 1 of 1
Contributors
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

display ip address
Shim
hello guys

i just wanted to share this
Code: Select all
<?php
$ip = $_SERVER['REMOTE_ADDR']; 
echo $ip; 
?>

live - http://shimsoftwares.com/ip.php
Find my programs on Softpedia
User avatar
rocky4126
VIP - Donator
VIP - Donator
Posts: 258
Joined: Mon Nov 16, 2009 7:39 pm

Re: display ip address
rocky4126
If your application is usable in both SSH and on the web, you can use
Code: Select all
<?php
if(PHP_SAPI){
	$ip = explode(" ",$_SERVER['SSH_CONNECTION']);
	$ip = $ip[0];
}else{
	$ip = $_SERVER['REMOTE_ADDR'];
}
?>
Image
2 posts Page 1 of 1
Return to “Help & Support”