问题描述
假设我收到如下请求:
http://www.example.com/index.php?id=123&version=3&id=234&version=4
是否可以在我的 php 代码中以简单的方式提取这些内容?我意识到我可以使用 window.location.href 使用 javascript 获取整个查询字符串并手动处理它,但我正在寻找更优雅的东西.请求可以包含任意数量的版本/ID 对,但我可以假设查询格式正确并且没有义务处理无效字符串.
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 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)