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实现合并数组以及保留键值的方法介绍