From 50913624567c1ea26928189b09c2043c4d32f004 Mon Sep 17 00:00:00 2001 From: Ian Irlen <45947370+kevinirlen@users.noreply.github.com> Date: Thu, 14 Jul 2022 20:18:31 +0400 Subject: [PATCH 1/2] Update http_foundation.rst I believe this is not the case anymore ``` When PHP imports the request query, it handles request parameters like ``foo[bar]=baz`` in a special way as it creates an array. The ``get()`` method doesn't support returning arrays, so you need to use the following code:: ``` It's on line 165 in this http_foundation.rst. From what I can see, the ``get()`` method can return arrays. See image (https://ibb.co/qB0qHKc) Given this url `contacts?foo[bar]=baz` .. I can do this ``` $request->query->get('foo'); // returns ['bar' => 'baz'] ``` Tested on a symfony 4.4 application. Am I missing something? --- components/http_foundation.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/http_foundation.rst b/components/http_foundation.rst index a9131112d1d..6e79c5cadce 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -162,16 +162,16 @@ exist:: $request->query->get('bar', 'baz'); // returns 'baz' -When PHP imports the request query, it handles request parameters like -``foo[bar]=baz`` in a special way as it creates an array. The ``get()`` method -doesn't support returning arrays, so you need to use the following code:: +To access request parameters like ``foo[bar]=baz``, you can use the following code:: // the query string is '?foo[bar]=baz' - // don't use $request->query->get('foo'); use the following instead: - $request->query->all('foo'); + $request->query->get('foo'); // returns ['bar' => 'baz'] + $request->query->get('foo')['bar']; + // retuns "baz" + // if the requested parameter does not exist, an empty array is returned: $request->query->all('qux'); // returns [] From 23ac40c636953d807f4e943610c2ff6c94152edf Mon Sep 17 00:00:00 2001 From: Kevin Irlen Date: Thu, 14 Jul 2022 20:43:25 +0400 Subject: [PATCH 2/2] Fix typo --- components/http_foundation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/http_foundation.rst b/components/http_foundation.rst index 6e79c5cadce..594ce070b4e 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -170,7 +170,7 @@ To access request parameters like ``foo[bar]=baz``, you can use the following co // returns ['bar' => 'baz'] $request->query->get('foo')['bar']; - // retuns "baz" + // returns "baz" // if the requested parameter does not exist, an empty array is returned: $request->query->all('qux'); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy