note 123926 rejected from function.array-shift by cmb
| From: | cmb@php.net | Date: | Wed, 12 Jun 2019 14:32:08 +0000 |
| Subject: | note 123926 rejected from function.array-shift by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211241@lists.php.net to get a copy of this message | ||
Note Submitter: wfoojjaec at gmail dot com
----
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.