加入收藏 | 设为首页 | 会员中心 | 我要投稿 开发网_郴州站长网 (http://www.0735zz.com/)- 云通信、区块链、物联设备、云计算、站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php 取得客户端IP地址代码

发布时间:2022-06-18 15:37:53 所属栏目:PHP教程 来源:互联网
导读:? //开源代码 function getip(){ if (getenv(http_client_ip) strcasecmp(getenv(http_client_ip), unknown)) $ip = getenv(http_client_ip); //开源 else if (getenv(http_x_forwarded_for) strcasecmp(getenv(http_x_forwarded_for), unknown)) $ip = gete
  <?
  //开源代码
   
  function getip(){  
               if (getenv("http_client_ip") && strcasecmp(getenv("http_client_ip"), "unknown"))  
  $ip = getenv("http_client_ip"); //开源  
               else if (getenv("http_x_forwarded_for") && strcasecmp(getenv("http_x_forwarded_for"), "unknown"))  
  $ip = getenv("http_x_forwarded_for"); //  
               else if (getenv("remote_addr") && strcasecmp(getenv("remote_addr"), "unknown"))  
  $ip = getenv("remote_addr");  
               else if (isset($_server[@#remote_addr@#]) && $_server[@#remote_addr@#] && strcasecmp($_server[@#remote_addr@#], "unknown"))
   
  //
   
  $ip = $_server[@#remote_addr@#];  
  else  
  $ip = "unknown";  
               return($ip);  
  }  
  ?>
   
  判断邮箱地址  
  <?  
  function checkemail($inaddress)  
  {  
  return (ereg("^([a-za-z0-9_-])+@([a-za-z0-9_-])+(.[a-za-z0-9_-])+",$inaddress));  
  } //phpfensi.com
  ?>
   
  <?  
  function getip() { //获取ip  
  if ($_server["http_x_forwarded_for"])  
  $ip = $_server["http_x_forwarded_for"]; //  
      else if ($_server["http_client_ip"])  
  $ip = $_server["http_client_ip"];  
      else if ($_server["remote_addr"])  
  $ip = $_server["remote_addr"]; //  
      else if (getenv("http_x_forwarded_for"))  
  $ip = getenv("http_x_forwarded_for");  
      else if (getenv("http_client_ip"))  
  $ip = getenv("http_client_ip"); //  
      else if (getenv("remote_addr"))  
  $ip = getenv("remote_addr");  
      else  
  $ip = "unknown";  
      return $ip;  
  }  
  ?>
 

(编辑:开发网_郴州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读