在URL中为同一个GET变量传递多个值 [英] Passing multiple values for same GET variable in URL

查看:115
本文介绍了在URL中为同一个GET变量传递多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  http是一种更简洁的方法://www.mysite.com/somepage?tags [] = one& tags [] = two& tags [] = three 

我想过以下几点:

  http://www.mysite.com/somepage? tags = one,two,three 

然后使用 explode()

想知道是否有人看到或使用过更好的解决方案吗?

解决方案使用 explode()是唯一可靠的,如果每个标签的值永远不会包含任何字符串你会爆炸(在这种情况下是,)。



我会说使用 tags [] = X&标记更安全[] = Y


I'm wondering if there is a cleaner way to pass multiple variables in a GET request than the following:

http://www.mysite.com/somepage?tags[]=one&tags[]=two&tags[]=three

I had thought about the following:

http://www.mysite.com/somepage?tags=one,two,three

Then using explode() to separate them.

Wondered if anyone had seen or used a better solution though?

解决方案

Using explode() is only reliable if the values of each tag will never contain whatever string it is you're exploding by (in this case ",").

I'd say it's safer to use tags[]=X&tags[]=Y.

这篇关于在URL中为同一个GET变量传递多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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