From: Slig at free dot fr Operating system: linux-64 PHP version: 5CVS-2007-09-14 (snap) PHP Bug Type: Variables related Bug description: missing error when assigning vars in reference arguments
Description: ------------ I know it has already be discused in #35995. I do not really agree with that feature (it's accepted by other languages like C, and after assignment it's a variable which is passed to the function), but if this syntax is forbidden then it should make an error, else it is really difficult to fix it in old programs. Also, because until 5.1.1 it worked like some of us expected, would be nice to add some warning about it in the documentation. Reproduce code: --------------- <?php function myFunc(&$var1) { $var1 = 'set in function'; } $var2 = 'set before function'; myFunc($var2 = 'set in function call'); var_dump($var2); ?> Expected result: ---------------- Fatal error: Cannot pass parameter 1 by reference in xxxx at line nn Actual result: -------------- No error, but the function get in $var1 the assigned value, and after the call $var2 get the assign value too (so not changed by the function) -- Edit bug report at http://bugs.php.net/?id=42674&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42674&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42674&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42674&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42674&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42674&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42674&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42674&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42674&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42674&r=support Expected behavior: http://bugs.php.net/fix.php?id=42674&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42674&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42674&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42674&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42674&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42674&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42674&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42674&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42674&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42674&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42674&r=mysqlcfg