Home > Backend Development > PHP Tutorial > How to get the client ip_PHP tutorial

How to get the client ip_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:22:21
Original
973 people have browsed it

How to get the client ip in php

How to get the client ip in php, simple and practical

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 tutorial

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

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

return $onlineip;

 }

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/848328.htmlTechArticlephp How to get the client ip php gets the client ip, simple and practical function getOnlineIP() { $cip = getenv ( 'HTTP_CLIENT_IP' ); $xip = getenv ( 'HTTP_X_FORWARDED_FOR' ); $rip = getenv (...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template