标签:style blog http io color os java sp div
测试网址:http://afish.cnblogs.com/p/3941211.html?id=1
//获取域名或主机地址 echo $_SERVER[‘HTTP_HOST‘]."<br />"; #afish.cnblogs.com //获取网页地址 echo $_SERVER[‘PHP_SELF‘]."<br />"; #/p/3941211.html //获取网址参数 echo $_SERVER["QUERY_STRING"]."<br />"; #id=1 //获取用户代理 echo $_SERVER[‘HTTP_REFERER‘]."<br />"; //获取完整的url echo ‘http://‘.$_SERVER[‘HTTP_HOST‘].$_SERVER[‘REQUEST_URI‘]; echo ‘http://‘.$_SERVER[‘HTTP_HOST‘].$_SERVER[‘PHP_SELF‘].‘?‘.$_SERVER[‘QUERY_STRING‘]; #http://afish.cnblogs.com/p/3941211.html?id=1 //包含端口号的完整url echo ‘http://‘.$_SERVER[‘SERVER_NAME‘].‘:‘.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; #http://afish.cnblogs.com:80/p/3941211.html?id=1 //只取路径 $url=‘http://‘.$_SERVER[‘SERVER_NAME‘].$_SERVER["REQUEST_URI"]; echo dirname($url); #http://afish.cnblogs.com/p
javascript获取url:
top.location.href 顶级窗口的地址 this.location.href 当前窗口的地址
标签:style blog http io color os java sp div
原文地址:http://www.cnblogs.com/afish/p/4057597.html