#36405 [Opn->Bgs]: inline assignment of a variable used as a reference fails
ID: 36405
Updated by: pajoye@php.net
Reported By: thom at genx dot net
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux (gentoo)
PHP Version: 5.1.2
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
$x = 'foo' is an expression and cannot be passed by reference. Enable
E_STRICT to see the message.
Previous Comments:
------------------------------------------------------------------------
[2006-02-16 00:33:18] thom at genx dot net
Description:
------------
Inline assignment of a variable used as an argument to a function
(passed by reference) does not behave properly. Earlier versions of
PHP (< 5.1.2) and other programming languages recognize the assignment
before the function call is made. It seems that PHP 5.1.2 recognizes
the assignment after the function call is made.
Reproduce code:
---------------
<?php
function testAppend(&$string)
{
$string .= 'testAppend';
}
testAppend($x = 'foo');
echo $x;
?>
Expected result:
----------------
footestAppend
Actual result:
--------------
foo
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36405&edit=1
Thread (7 messages)