Home  >  Article  >  Backend Development  >  php Get local IP code_PHP tutorial

php Get local IP code_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:03:401254browse

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...
Statement:
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