Home>Article>Backend Development> PHP Get current URL

PHP Get current URL

巴扎黑
巴扎黑 Original
2016-11-08 11:21:06 1388browse

     PHP中获取当前URL 
'; echo $_SERVER['HTTP_HOST']."
"; echo '获取网页地址:
'; echo $_SERVER['PHP_SELF']."
"; echo '获取网址参数:
'; echo $_SERVER["QUERY_STRING"]."
"; echo '获取完整的url:
'; echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."
"; echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']."
"; echo '包含端口号的完整url:
'; echo 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]."
"; $url='http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"]."
"; echo dirname($url); ?>

PHP Get current URL

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