diff --git a/components/http_foundation/introduction.rst b/components/http_foundation/introduction.rst index c370c3e0ae8..62546cefb2b 100644 --- a/components/http_foundation/introduction.rst +++ b/components/http_foundation/introduction.rst @@ -147,25 +147,28 @@ exist:: // the query string is '?foo=bar' $request->query->get('foo'); - // returns bar + // returns 'bar' $request->query->get('bar'); // returns null - $request->query->get('bar', 'bar'); - // returns 'bar' + $request->query->get('bar', 'baz'); + // returns 'baz' When PHP imports the request query, it handles request parameters like ``foo[bar]=bar`` in a special way as it creates an array. So you can get the ``foo`` parameter and you will get back an array with a ``bar`` element:: - // the query string is '?foo[bar]=bar' + // the query string is '?foo[bar]=baz' $request->query->get('foo'); - // returns array('bar' => 'bar') + // returns array('bar' => 'baz') $request->query->get('foo[bar]'); - // returns null + // returns null + + $request->query->get('foo')['bar']; + // returns 'baz' .. _component-foundation-attributes: