Bug #52133 [Opn->Fbk]: Functions cannot return an argument passed by reference as reference

From: Date: Tue, 22 Jun 2010 22:29:01 +0000
Subject: Bug #52133 [Opn->Fbk]: Functions cannot return an argument passed by reference as reference
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-151777@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52133&edit=1

 ID:               52133
 Updated by:       johannes@php.net
 Reported by:      bschussek at gmail dot com
 Summary:          Functions cannot return an argument passed by
                   reference as reference
-Status:           Open
+Status:           Feedback
 Type:             Bug
 Package:          Scripting Engine problem
 Operating System: Linux Ubuntu 10.04
 PHP Version:      5.3.2

 New Comment:

Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


Previous Comments:
------------------------------------------------------------------------
[2010-06-21 13:56:07] 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)


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52133&edit=1


Thread (7 messages)

« previous php.bugs (#151777) next »