Skip to content

Reworded the example about $deep param #6390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions components/http_foundation/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only thing I don't understand is why do you keep this example since the PropertyAccessor syntax isn't possible anymore (or just deprecated in 2.8) :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this example the query string is ?foo[bar]=baz That's why I suppose that most people will think that foo[bar] will return baz. It looks common sense! So putting this example and returning null will make them realize that this doesn't work as they expect.


$request->query->get('foo')['bar'];
// returns 'baz'

.. _component-foundation-attributes:

Expand Down