PHP determines the method of accessing IP, PHP determines ip_PHP tutorial

WBOY
Release: 2016-07-13 09:49:28
Original
1396 people have browsed it

php determines the method of accessing the IP, php determines the ip

The example in this article describes the method of php determining the access IP. Share it with everyone for your reference. The details are as follows:

<&#63;php 
function getIP() { 
  if (! empty ( $_SERVER ["HTTP_CLIENT_IP"] )) { 
    $cip = $_SERVER ["HTTP_CLIENT_IP"]; 
  } else if (! empty ( $_SERVER ["HTTP_X_FORWARDED_FOR"] )) { 
    $cip = $_SERVER ["HTTP_X_FORWARDED_FOR"]; 
  } else if (! empty ( $_SERVER ["REMOTE_ADDR"] )) { 
    $cip = $_SERVER ["REMOTE_ADDR"]; 
  } else { 
    $cip = ''; 
  } 
  preg_match ( "/[\d\.]{7,15}/", $cip, $cips ); 
  $cip = isset ( $cips [0] ) &#63; $cips [0] : 'unknown'; 
  unset ( $cips ); 
  return $cip; 
} 
&#63;>

Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1019454.htmlTechArticlephp method to determine access IP, php determine ip This article describes the method of php to determine access IP. Share it with everyone for your reference. The details are as follows: php function getIP() { if (! empty ( $_S...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template