为什么$_REQUEST在获取相同的参数时,在不同的情况下会返回不同的值?

发布于 2024-09-30 12:33:17 字数 313 浏览 0 评论 0原文

我有两个 URL,其中包含参数“tour_date”,我试图在 PHP 中读出该参数。对第一个 URL:

.php?tour_id=336&tour_date=11/06/2010

运行 $_REQUEST["tour_date"]返回值: 11/06/2010

而第二个 URL:

. php?tour_id=336&tour_date=11/06/2010

不返回任何内容。我已经运行了empty()方法来测试,它确实没有找到它。关于为什么会发生这种情况有什么想法吗?感谢您的帮助!

I have two URL's which contain the parameter "tour_date" which I am trying to read out in PHP. Running $_REQUEST["tour_date"] for the first URL:

.php?tour_id=336&tour_date=11/06/2010

returns the value of: 11/06/2010

While the second URL:

.php?tour_id=336&tour_date=11/06/2010

returns nothing. I've run the empty() method to test, and it indeed is not finding it. Any ideas on why this would happen? Thanks for your help!

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

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

发布评论

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

评论(2

望她远 2024-10-07 12:33:17

$_REQUEST 是一个超全局变量,它结合了 $_GET、$_POST 和 $_COOKIE(默认按此顺序)
如果您的 POST 或 COOKIE 还将tour_date 设置为空字符串,则 REQUEST 值将被覆盖

$_REQUEST is a superglobal that combines $_GET, $_POST and $_COOKIE (in this order by default)
if your POST or COOKIE also set tour_date to an empty string, then the REQUEST values get overwritten

一念一轮回 2024-10-07 12:33:17

您可以尝试将 var_dump($_REQUEST); 放入代码中,看看这是否为您指明了正确的方向。

另外,请确保您没有仅与单个“=”进行比较。

if($_REQUEST["tour_date"] = ""){ 所示。这将返回 true 并将tour_date 设置为空。

You could try putting var_dump($_REQUEST); in your code to see if that points you in the right direction.

Also, make sure you don't have a comparison with only a single "=".

As in if($_REQUEST["tour_date"] = ""){. This will return true and also set tour_date to empty.

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