#35075 [Opn->Bgs]: Assignment by reference using a function assignes the variable by value
ID: 35075
Updated by: iliaa@php.net
Reported By: skrol29 at freesurf dot fr
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Windows XP
PHP Version: 5.0.5
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
You cannot return a reference to a literal, if you rewrite your code in
the following manner it works properly.
<?php
$a = 'hello'; $b =& $a;
$a = &f_test();
echo "* a = {".$a."}, b = {".$b."}\n";
function &f_test() {
$a = 'tested';
return $a;
}
?>
Previous Comments:
------------------------------------------------------------------------
[2005-11-03 10:24:00] skrol29 at freesurf dot fr
The same bug occurs with this last Php version (pompted version was
5.0.6-dev).
------------------------------------------------------------------------
[2005-11-03 09:10:26] derick@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.0-win32-latest.zip
------------------------------------------------------------------------
[2005-11-03 01:47:25] skrol29 at freesurf dot fr
Description:
------------
This bug is a change of Assignment by reference behavior bewteen Php
versions <= 5.0.4 and the last 5.0.5.
In Php 5.0.5 when a variable is re-assigned by reference directly using
a function, then the variable is assigned by value.
Reproduce code:
---------------
<?php
$a = 'hello';
$b =& $a;
$a =& f_test();
echo "* a = {".$a."}, b = {".$b."}<br>";
function f_test() {
return 'tested';
}
?>
Expected result:
----------------
* a = {tested}, b = {hello}
Actual result:
--------------
* a = {tested}, b = {tested}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35075&edit=1
Thread (5 messages)