学新通

PHP获取当前页面的URL地址

原创 12847 124
PHP获取当前页面的URL地址 PHP获取当前页面的URL地址

本文出至:学新通博客

//获取域名或主机地址  blog.swvq.com
echo $_SERVER['HTTP_HOST']; 
//获取网页地址  /Article/articleshow/id/191.html
echo $_SERVER['PHP_SELF']; #/blog/testurl.php
//获取网址参数  /Article/articleshow/id/191.html
echo $_SERVER["QUERY_STRING"]; 
//获取用户代理  IP
echo $_SERVER['HTTP_REFERER']; 
//获取完整的url https://blog.swvq.com/Article/articleshow/id/191.html
echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
//包含端口号的完整url  https://blog.swvq.com:80/Article/articleshow/id/191.html
echo 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; 
//只取路径 http://localhost/blog
$url='http://'.$_SERVER['SERVER_NAME&#本文出至:学新通博客网络博客本文出至:学新通博客网络博客39;].$_SERVER["REQUEST_URI"]; 
echo dirname($url);


本文出至:学新通博客

标签: