ID:               36191
 User updated by:  mail dot spam at gmx dot net
 Reported By:      mail dot spam at gmx dot net
 Status:           Bogus
 Bug Type:         *General Issues
 Operating System: Windows
 PHP Version:      5.1.2
 New Comment:

Thanks for your replay, I reread the manual and found the line you
meant

But I still think it's a bug:

This code:
---------
function test_func(&$test_param) {
  echo 'inside before:';
  print_r($test_param);
  $test_param[] = 2;
  echo 'inside after:';
  print_r($test_param);
}

echo '<pre>';
echo 'outside before function call:';
print_r($test_array);
test_func($test_array = array(1));
echo 'outside after function call:';
print_r($test_array);
echo '</pre>'; 
---------
displays the following:
---------
outside before function call:

Notice:  Undefined variable: test_array in <filename goes here> on line
13

inside before:Array
(
    [0] => 1
)
inside after:Array
(
    [0] => 1
    [1] => 2
)
outside after function call:Array
(
    [0] => 1
)
---------
As you can see the expression I try to pass as argument gets evaluated
twice.
One time before calling the function itself (which is the behaviour
like in all earlier version) and a second time after returning from the
function call

If the expression got evaluated only one time (after returning from
function call) I'ld say its ok, you changed things a little bit.
But as you seem to execute the code two times I can't imagine why you
added this second execution?


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

[2006-01-29 16:08:52] [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



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

[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

Reply via email to