本文实例为大家分享了php获取本机真实IP地址实例代码,供大家参考.
function
getLocalIP()
{
$preg
=
exec("ipconfig",
$out,
$stats);
if
(!empty($out))
foreach
($out
AS
$row)
(strstr($row,
"IP")
strstr($row,
":")
!strstr($row,
$tmpIp
explode(":",
$row);
(preg_match($preg,
trim($tmpIp[1])))
return
trim($tmpIp[1]);
}
//获取操作系统为linux类型的本机IP真实地址
exec("ifconfig",
(isset($out[1])
strstr($out[1],
'addr:'))
$tmpArray
$out[1]);
explode("
",
$tmpArray[1]);
trim($tmpIp[0])))
trim($tmpIp[0]);
以上就是土嘎嘎小编为大家整理的php获取如何获取真实ip相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!