A simple IP address acquisition code, but this can only obtain the IP on the server and cannot be used on the client. Friends in need can refer to it.
The code is as follows
代码如下 |
复制代码 |
/**
* 获取服务器的ip
* @access public
* @return string
**/
function real_server_ip(){
static $serverip = NULL;
if ($serverip !== NULL){
return $serverip;
}
if (isset($_SERVER)){
if (isset($_SERVER['SERVER_ADDR'])){
$serverip = $_SERVER['SERVER_ADDR'];
}
else{
$serverip = '0.0.0.0';
}
}
else{
$serverip = getenv('SERVER_ADDR');
}
return $serverip;
}
|
|
Copy code |
|
/**
* Get the server’s ip
* @access public
* @return string
**/
function real_server_ip(){
static $serverip = NULL;
if ($serverip !== NULL){
return $serverip;
}
if (isset($_SERVER)){
if (isset($_SERVER['SERVER_ADDR'])){
$serverip = $_SERVER['SERVER_ADDR'];
}
else{
$serverip = '0.0.0.0';
}
}
else{
$serverip = getenv('SERVER_ADDR');
}
return $serverip;
}
http://www.bkjia.com/PHPjc/631682.htmlwww.bkjia.com
trueTechArticleA simple IP address acquisition code, but this can only obtain the IP on the server and cannot be used on the client Oh, please refer to it if you need it. The code is as follows Copy code /** * Get the server...