加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

如何使用PHP获取脚本的当前URL?

发布时间:2020-12-13 14:05:06 所属栏目:PHP教程 来源:网络整理
导读:参见英文答案 getting current URL2 如何使用PHP获取脚本的当前URL? 请参阅 PHP Get Current URL: Sometimes it is not as straightforward as one may think to get the current url to use it inside your application. Here is a snippet that I use to
参见英文答案 > getting current URL2
如何使用PHP获取脚本的当前URL?
请参阅 PHP Get Current URL:

Sometimes it is not as straightforward
as one may think to get the current
url to use it inside your application.
Here is a snippet that I use to fetch
the current URL and use it in a
script. The current url (whether http
or https) is now a local variable that
you can do with as you please.

$url = "http".(!empty($_SERVER['HTTPS'])?"s":"").
"://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

Note: You should groom this value before using in anything sensitive,like a sql query.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读