php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41780 Engine silently ignores call by reference
Submitted: 2007-06-22 15:03 UTC Modified: 2007-06-23 20:00 UTC
From: kettler at gmx dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.3 OS: Linux 2.6.20.2 / Debian Sarge
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kettler at gmx dot net
New email:
PHP Version: OS:

 

 [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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-23 00:30 UTC] 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-23 20:00 UTC] sniper@php.net
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


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 10:01:34 2025 UTC