Blogger Information
Blog 263
fans 3
comment 2
visits 113278
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
获取客户端IP与服务器IP及域名
福哥的博客
Original
1445 people have browsed it

打印客户端IP:

<?php
echo $_SERVER['REMOTE_ADDR']; 
echo "<hr>";
echo getenv('REMOTE_ADDR');//getenv取得开发环境变量
?>

打印服务器IP :

<?php
echo gethostbyname("www.bolaiwu.com") // gethostbyname取得IP地址函数
?>

获取域名 :

<?php
$url=$_SERVER["HTTP_REFERER"];//获取完整***路URL
$str=str_replace("http://","",$url);//去掉http://
$strdomain = explode("/",$str); //以“/”分开成数组
$domain=$strdomain[0]; //取第一个“/”以前的字符,也就是域名了
//var_dump($_SERVER);
?>


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post