HTTP查询字符串和[] [英] HTTP query string and []

查看:158
本文介绍了HTTP查询字符串和[]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP在查询参数名称中使用 [] ,以确保参数的多次出现都存在于 $ _ GET 超全局变量。 (否则只出现最后一次。)(任何其他软件都这样做?)

PHP uses [] in query parameter names to ensure that multiple occurrences of a parameter are all present in $_GET superglobal variable. (Otherwise only last occurrence is present.) (Any other software does that?)

但是来自 RFC 3986 (以及其他人)似乎既不是 [也不是]

But from RFC 3986 (and others as well) it seems that neither [ nor ] are allowed in query string.

然而,我对各种浏览器的实验表明,没有浏览器对这些字符进行编码,它们就像URI一样存在于URI中。 。

Yet my experiments with various browsers suggested that no browser encodes those characters and they are there in the URI just like that...

这是现实生活吗?或者我测试不正确?我在IIS 7上使用PHP 5.3.17进行了测试。使用Internet Explorer,Firefox和Chrome。然后我比较了 $ _ SERVER ['QUERY_STRING'] $ _ GET 中的内容。

Is this real life practice? Or am I testing it incorrectly? I tested with PHP 5.3.17 on IIS 7. Using Internet Explorer, Firefox and Chrome. Then I compared what is in $_SERVER['QUERY_STRING'] and $_GET.

推荐答案

这是常见的做法。这是一种将数组传递到后端脚本的方法,并且可以使用ASP和PHP(从未使用ASP.net进行测试,但在2004年使用ASP时常见的做法)。据我所知,没有其他方法可以将数组传递给您的脚本,除非您使用javascript和 .join 或类似的东西。

It is common practice. It's a way of passing arrays in to the back-end script, and works with ASP and PHP (Never tested with ASP.net, but was common practice when I used ASP back in ~2004). As far as I know, there is not another way to pass an array to your script unless you use javascript and .join or something similar.

您可以查看 http:// www .thefutureoftheweb.com / blog / use-arrays-with-html-form-inputs 作为如何使用HTML表单中的数组传递给后端的参考之一。虽然,公平地说,大多数时候它们与'POST'一起使用而不是'GET'。

You can view http://www.thefutureoftheweb.com/blog/use-arrays-with-html-form-inputs as one of the references of how to use arrays within your HTML forms to be passed to your backend. Though, to be fair, most of the time they are used in conjunction with 'POST' rather than 'GET'.

这篇关于HTTP查询字符串和[]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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