我需要从当前请求的 URL 中获取路径。例如,如果当前 URL 是:
"http://www.example.com/example/test/hi.php?randomvariable=1"
我想要这个:
"/example/test/hi.php?randomvariable=1"
最佳答案
你想要 $_SERVER['REQUEST_URI']
。来自 the docs :
'REQUEST_URI'
The URI which was given in order to access this page; for instance,
'/index.html'
.
关于php - 在 PHP 中获取带有查询字符串的当前 URL 路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16198790/