具有相同标识符的多个HTTP GET参数 [英] Multiple HTTP GET parameters with the same identifier

查看:98
本文介绍了具有相同标识符的多个HTTP GET参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我收到以下请求:

http://www.example.com/index.php?id=123&version=3&id=234&version=4

是否有可能以一种简单的方式在我的php代码中提取这些内容?我意识到我可以使用window.location.href使用javascript获取整个查询字符串并手动处理它,但我正在寻找更优雅的东西.这些请求可以包含任意数量的版本/标识对,但是我可以假定查询的格式正确,并且没有义务处理无效的字符串.

Is it possible to extract these in a simple way inside my php code? I realize I could get the entire querystring with javascript using window.location.href and handle it manually but I'm looking for something more elegant. The requests can contain any number of version/id pairs but I can assume that the query is well-formed and have no obligation to handle invalid strings.

推荐答案

根据这是PHP手册中的注释,PHP的查询字符串解析器将删除重复的参数...因此,我认为PHP不适合您要执行的操作(除非它具有具有与javascript相同的功能来获取原始查询字符串,您可以用它来做任何想要的事情)

According to this comment from the PHP manual, PHP's query string parser will drop duplicate params... so I don't think that PHP is a good fit for what you want to do (except in that it has the same capacity as javascript to get the raw query string, with which you can do whatever you want)

这篇关于具有相同标识符的多个HTTP GET参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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