|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-06-22 15:03 UTC] kettler at gmx dot net
Description:
------------
The scripting engine silently ignores the pass by reference mandated by certain function, e.g. array_pop() under certain conditions.
The "Reproduce code" should either work as in PHP 4 (i.e. remove the last element of the $array array) or give an error as it does when you try passing a literal array.
Anything else is counter-intuitive as no required pass by reference is being used.
Reproduce code:
---------------
$input = '1.2.3';
array_pop($array = explode('.', $input));
print implode('.', $array);
Expected result:
----------------
Fatal error: Only variables can be passed by reference in script on line 2
Actual result:
--------------
1.2.3
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 16:00:01 2025 UTC |
The error message you expect is correct, however PHP is a dynamic language, and as such it should allow the behaviour you explain in some situations where it can continue without problems. Some older versions of PHP aborts with the mentioned error with your code, however it caused a lot of complains about backward compatibility break and the engine code has been modified in order to only emit this error message on certain situations like this: $input = '1.2.3'; array_pop(explode('.', $input) + array()); Please dont suggest backward incompatible changes. we have enough of this already.