#41780 [Opn->Bgs]: Engine silently ignores call by reference
ID: 41780
Updated by: sniper@php.net
Reported By: kettler at gmx dot net
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux 2.6.20.2 / Debian Sarge
PHP Version: 5.2.3
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2007-06-23 00:30:15] judas dot iscariote at gmail dot com
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.
------------------------------------------------------------------------
[2007-06-22 15:03:16] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41780&edit=1
Thread (3 messages)