Home > Backend Development > PHP Tutorial > php Get local IP code_PHP tutorial

php Get local IP code_PHP tutorial

WBOY
Release: 2016-07-21 15:03:40
Original
1321 people have browsed it

Copy code The code is as follows:

function get_client_ip()
{
if ($_SERVER ['REMOTE_ADDR']) {
$cip = $_SERVER['REMOTE_ADDR'];
} elseif (getenv("REMOTE_ADDR")) {
$cip = getenv("REMOTE_ADDR");
} elseif (getenv("HTTP_CLIENT_IP")) {
$cip = getenv("HTTP_CLIENT_IP");
} else {
$cip = "unknown";
}
return $ cip;
}
echo "Your IP address is:".get_client_ip();
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327832.htmlTechArticleCopy the code as follows: ? function get_client_ip() { if ($_SERVER['REMOTE_ADDR']) { $cip = $_SERVER['REMOTE_ADDR']; } elseif (getenv("REMOTE_ADDR")) { $cip = getenv("REMOTE_ADDR...
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