note 123926 added to function.array-shift
| From: | wfoojjaec at gmail dot com | Date: | Tue, 11 Jun 2019 10:02:33 +0000 |
| Subject: | note 123926 added to function.array-shift | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-211234@lists.php.net to get a copy of this message | ||
Using this code:
$value = array_shift( a_function_that_returns_array() );
May result in a memory leak, as of PHP 7.3.5 (cli) (built: Apr 30 2019 21:05:09), while this one
does not:
$value = a_function_that_returns_array()[ 0 ];
It seems that this is not a bug and does generate a warning about passing values by reference.
----
Server IP: 208.43.231.9
Probable Submitter: 185.85.3.195 (proxied: 5.248.205.243)
----
Manual Page -- http://php.net/manual/en/function.array-shift.php
Edit -- https://master.php.net/note/edit/123926
Del: integrated -- https://master.php.net/note/delete/123926/integrated
Del: useless -- https://master.php.net/note/delete/123926/useless
Del: bad code -- https://master.php.net/note/delete/123926/bad+code
Del: spam -- https://master.php.net/note/delete/123926/spam
Del: non-english -- https://master.php.net/note/delete/123926/non-english
Del: in docs -- https://master.php.net/note/delete/123926/in+docs
Del: other reasons-- https://master.php.net/note/delete/123926
Reject -- https://master.php.net/note/reject/123926
Search -- https://master.php.net/manage/user-notes.php