#39614 [Opn->Bgs]: assignment reference returned by function

From: Date: Fri, 24 Nov 2006 10:09:09 +0000
Subject: #39614 [Opn->Bgs]: assignment reference returned by function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-105400@lists.php.net to get a copy of this message
ID: 39614 Updated by: derick@php.net Reported By: sailormax at inbox dot lv -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: any PHP Version: 5.2.0 New Comment: If you return by reference, you need to assign the returned value by reference as well. This is also true for PHP 4.4.x, but not earlier versions where this usage would create a memory corruption. Previous Comments: ------------------------------------------------------------------------ [2006-11-24 09:55:39] sailormax at inbox dot lv Description: ------------ PHP 4.x.x, returned value by reference, assign to variable reference. But 5.x.x assign copy of value... Reproduce code: --------------- function &ret_ref(&$arr) { return $arr; } $arr = array("111111", "2222222", "33333333"); $test = ret_ref($arr); $test[] = "4444444444"; print_r($arr); Expected result: ---------------- Array ( [0] => 111111 [1] => 2222222 [2] => 33333333 [3] => 4444444444 ) Actual result: -------------- Array ( [0] => 111111 [1] => 2222222 [2] => 33333333 ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39614&edit=1

« previous php.bugs (#105400) next »