#36191 [Opn->Bgs]: statement as function parameter gets evaluated after calling the function
ID: 36191
Updated by: sniper@php.net
Reported By: mail dot spam at gmx dot net
-Status: Open
+Status: Bogus
Bug Type: *General Issues
Operating System: Windows
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
Previous Comments:
------------------------------------------------------------------------
[2006-01-28 14:01:59] mail dot spam at gmx dot net
Description:
------------
if you use a statement as actual parameter for a function (parameter is
called by reference) the statement get's executed after calling the
function thus overwriting the function's work
Reproduce code:
---------------
function test_array(&$test) {
$test[] = 2;
}
echo '<pre>';
test_array($test_1);
test_array($test_2 = array(1));
$test_3 = array(1);
test_array($test_3);
print_r($test_1);
print_r($test_2);
print_r($test_3);
echo 'PHP-Version: '.phpversion();
echo '</pre>';
Expected result:
----------------
Array
(
[0] => 2
)
Array
(
[0] => 1
[1] => 2
)
Array
(
[0] => 1
[1] => 2
)
Actual result:
--------------
output for version 4.3.11
Array
(
[0] => 2
)
Array
(
[0] => 1
[1] => 2
)
Array
(
[0] => 1
[1] => 2
)
output for version 5.1.2
Array
(
[0] => 2
)
Array
(
[0] => 1
)
Array
(
[0] => 1
[1] => 2
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36191&edit=1
Thread (3 messages)