//统一获取服务器IP地址代码
$the_local_ip= '';
$result= shell_exec("/sbin/ifconfig");
if (preg_match_all("/inet (\d+\.\d+\.\d+\.\d+)/", $result, $match)!== 0){
foreach ($match [0]as $k => $v) {
if ($match [1] [$k]!= "127.0.0.1") {
$the_local_ip= $match [1] [$k];
}
}
}
$serverIp= !empty($the_local_ip)? $the_local_ip: '127.0.0.1';
网友评论