如何在PHP中获取当前页面的URL [英] How to get URL of current page in PHP

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

问题描述

在PHP中,如何获取当前页面的URL?最好是 http://domain.com 之后的部分.

In PHP, how can I get the URL of the current page? Preferably just the parts after http://domain.com.

推荐答案

$_SERVER['REQUEST_URI']

有关$ _SERVER数组中可用信息的更多详细信息,请参见相应的PHP手册页.

For more details on what info is available in the $_SERVER array, see the PHP manual page for it.

如果您还需要查询字符串(URL中?之后的位),则该部分位于此变量中:

If you also need the query string (the bit after the ? in a URL), that part is in this variable:

$_SERVER['QUERY_STRING']

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

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