欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP 获取当前 URL

程序员文章站 2022-03-25 15:39:49
...

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 获取当前 URL