[英]How to get value for multivalued get parameter in symfony2
如何獲取作為值列表的get參數的值? 我嘗試使用request->query->get('parameter')
但這僅返回一個值。
假設您有一個國家/地區參數,並且想要傳遞多個值。 例如... ?country=us,gb
使用get只會給您'us'。
我在文檔中找不到這個。
您必須以這種方式格式化查詢參數
country[]=us&country[]=gb
從他們的手冊中(http://symfony.com/doc/current/book/http_fundamentals.html)
use Symfony\Component\HttpFoundation\Request;
$request = Request::createFromGlobals();
$request->query->get('foo');
編輯:
抱歉,我誤解了你的問題。 您想要像$ _GET這樣的所有GET變量數組嗎?
可以通過以下方式完成(還將包括POST參數):
<?php $request->getParameterHolder()->getAll();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.