|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-06-21 13:56 UTC] bschussek at gmail dot com
Description:
------------
PHP does not behave as expected when passing arguments by reference into a
function that are passed out again by reference.
IMO, the below test script should behave equivalently to the following code
(which produces the expected result):
$b = 'foobar';
$a =& $b;
$c =& $a;
$c[2] = 'z';
var_dump($c);
var_dump($b);
Test script:
---------------
function &ref(&$a)
{
return $a;
}
$b = 'foobar';
$c = ref($b);
$c[2] = 'z';
Expected result:
----------------
string 'fozbar' (length=6)
string 'fozbar' (length=6)
Actual result:
--------------
string 'fozbar' (length=6)
string 'foobar' (length=6)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 23:00:01 2025 UTC |
Sorry, but the test script produces still the wrong output for me. $ php -v PHP 5.3.3-dev (cli) (built: Jun 23 2010 00:45:57) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans $ php test.php string(6) "foobar" string(6) "fozbar"