Bug #71975 [NEW]: Passing by reference vs. switch

From: Date: Wed, 06 Apr 2016 11:22:21 +0000
Subject: Bug #71975 [NEW]: Passing by reference vs. switch
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200405@lists.php.net to get a copy of this message
From: deem at deem dot ru Operating system: PHP version: 7.0.5 Package: Variables related Bug Type: Bug Bug description:Passing by reference vs. switch Description: ------------ When variable passed by reference is used in switch() it becomes local for that scope Test script: --------------- <?php function bug( &$var ) { switch( $var ) { case 1: $var = 2; } } function workaround( &$var ) { $val_local = $var; switch( $val_local ) { case 1: $var = 2; } } $var = 1; bug( $var ); echo $var , PHP_EOL; $var = 1; workaround( $var ); echo $var , PHP_EOL; ?> -- Edit bug report at https://bugs.php.net/bug.php?id=71975&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71975&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71975&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71975&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71975&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71975&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71975&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71975&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71975&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71975&r=support Expected behavior: https://bugs.php.net/fix.php?id=71975&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71975&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71975&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71975&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71975&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71975&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71975&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71975&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71975&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71975&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71975&r=mysqlcfg

« previous php.bugs (#200405) next »