如何在 php 中一致地从查询中检索路径信息? (/index.php/foo/bar)

发布于 2024-08-08 13:54:18 字数 244 浏览 3 评论 0原文

基本上,如果用户请求:

index.php/foo/bar

我需要“/foo/bar”,而

index.php

我需要“”或“/”,

我在谷歌上找不到任何信息,因为我不知道这叫什么(路径信息让我得到了路径信息) () 函数)

我发现 PHP_SELF 在有路径信息的情况下返回的结果与没有路径信息的情况不同

Basically if the user requests:

index.php/foo/bar

I need "/foo/bar" and for

index.php

I need "" or "/"

I couldn't find any information on google because I don't know what this is called (path info got me the pathinfo() function)

I found PHP_SELF returns differently if there is path info than if there is no info

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不回头走下去 2024-08-15 13:54:18

文件名 /index.php 之后的部分称为路径信息(请参阅Apache 的 AcceptPathInfo 指令)。您可以使用 $_SERVER['PATH_INFO']< 访问该信息/代码>变量。如果您想要带有查询的完整请求 URL 路径,请使用 $_SERVER['REQUEST_URI']

The portion after your file name /index.php is called the path info (see Apache’s AcceptPathInfo directive). You can access that information with the $_SERVER['PATH_INFO'] variable. And if you want the full requested URL path with query, use $_SERVER['REQUEST_URI'].

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文