From:             jazfresh at hotmail dot com
Operating system: Linux Fedora Core 5
PHP version:      5.1.2
PHP Bug Type:     *General Issues
Bug description:  Variable initialization in function happens after function 
call

Description:
------------
If a variable is initialized inside a function call (e.g. foo($bar,
$baz=3) ) and that parameter is a reference, then the variable cannot be
altered by the function. It works ok if the variable is initialized
outside the function call.

This bug exists in PHP 5.1.2. It does not exist in 5.0.3. I checked the
changelogs and release notes for all versions inbetween, but I did not
find anything that indicated that the language changed in this way.

Reproduce code:
---------------
function foo(&$bar) {
    echo "Parameter is $bar\n";
    $bar = "baz";
}

foo($woz = "abc");
echo "Woz is $woz\n";

$bliz = "abc";
foo($bliz);
echo "Bliz is $bliz\n";


Expected result:
----------------
Parameter is abc
Woz is baz
Parameter is abc
Bliz is baz


Actual result:
--------------
Parameter is abc
Woz is abc
Parameter is abc
Bliz is baz


-- 
Edit bug report at http://bugs.php.net/?id=37141&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=37141&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=37141&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=37141&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=37141&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=37141&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=37141&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=37141&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=37141&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=37141&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=37141&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=37141&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=37141&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=37141&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=37141&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=37141&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=37141&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=37141&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=37141&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=37141&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=37141&r=mysqlcfg

Reply via email to