go to bug id or search bugs for
In the code sample provided, for some reason, $nonexistentElement gets assigned a value of 5. I'd expect this to trigger an error.
$params = array('search'=>'5');
$nonexistentElement = $params['search']['filter'];
Add a Patch
Add a Pull Request
It's an unfortunate quirk but it's not a bug. You're doing string access by character index. The string 'filter' gets parsed as an integer, which yields 0 since it's an invalid number, and the character at index 0 in the string '5' is '5'. See the warning here:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php
Thank you both. Because of this, I've switched to using an object in place of an array where I noticed this behavior.
By the way,
The correct pseudo code is:
Related To: Bug #63356