获取PHP中的当前URL路径 [英] Get current URL path in PHP

查看:67
本文介绍了获取PHP中的当前URL路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从当前请求的URL获取路径.例如,如果当前URL是:

I need to get the path from the URL of the current request. For example, if the current URL is:

"http://www.example.com/example/test/hi.php?randomvariable=1"

我想要这个:

"/example/test/hi.php?randomvariable=1"

推荐答案

您要$_SERVER['REQUEST_URI'].来自文档:

'REQUEST_URI'

为访问该页面而给出的URI;例如'/index.html'.

'REQUEST_URI'

The URI which was given in order to access this page; for instance, '/index.html'.

这篇关于获取PHP中的当前URL路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆