首页  >  文章  >  后端开发  >  php如何获取客户端ip_PHP教程

php如何获取客户端ip_PHP教程

WBOY
WBOY原创
2016-07-13 10:22:21926浏览

php如何获取客户端ip

   php获取客户端ip,简单实用

  function getOnlineIP() {

  $cip = getenv ( 'HTTP_CLIENT_IP' );

  $xip = getenv ( 'HTTP_X_FORWARDED_FOR' );

  $rip = getenv ( 'REMOTE_ADDR' );

  $srip = $_SERVER ['REMOTE_ADDR'];

  if ($cip && strcasecmp ( $cip, 'unknown' )) {

  $onlineip = $cip;

  } elseif ($xip && strcasecmp ( $xip, 'unknown' )) {

  $onlineip = $xip;

  } elseif ($rip && strcasecmp ( $rip, 'unknown' )) {

  $onlineip = $rip;

  } elseif ($srip && strcasecmp ( $srip, 'unknown' )) {

  $onlineip = $srip;

  }

  // 烈火网(LieHuo.Net)教程

  preg_match ( "/[\d\.]{7,15}/", $onlineip, $match );

  $onlineip = $match [0] ? $match [0] : 'unknown';

  return $onlineip;

  }

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/848328.htmlTechArticlephp如何获取客户端ip php获取客户端ip,简单实用 function getOnlineIP() { $cip = getenv ( 'HTTP_CLIENT_IP' ); $xip = getenv ( 'HTTP_X_FORWARDED_FOR' ); $rip = getenv (...
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn