ID:               35075
 User updated by:  skrol29 at freesurf dot fr
 Reported By:      skrol29 at freesurf dot fr
 Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Windows XP
 PHP Version:      5.0.5
 New Comment:

Hello,

That is correct, the manual says "The [assignement] syntax can be used
with functions, that return references".
So the function should return reference to be assigned properly by
reference to a variable.

Nevertheless it could be intersting to warn about that change of
behavior which occurse on version 5.0.5. Because no PHP Error message
neither Notice are prompted when the function doesn't return
references.


Previous Comments:
------------------------------------------------------------------------

[2005-11-03 15:50:00] [EMAIL PROTECTED]

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;
}
?>

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

[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] [EMAIL PROTECTED]

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

Reply via email to