Bug #71975 [Opn->Dup]: Passing by reference vs. switch

From: Date: Thu, 07 Apr 2016 06:18:57 +0000
Subject: Bug #71975 [Opn->Dup]: Passing by reference vs. switch
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200386@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71975&edit=1 ID: 71975 Updated by: nikic@php.net Reported by: deem at deem dot ru Summary: Passing by reference vs. switch -Status: Open +Status: Duplicate Type: Bug Package: Variables related PHP Version: 7.0.5 Block user comment: N Private report: N New Comment: Duplicate of bug #71914 (fixed in PHP 7.0.6). Previous Comments: ------------------------------------------------------------------------ [2016-04-06 11:22:17] deem at deem dot ru 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 this bug report at https://bugs.php.net/bug.php?id=71975&edit=1

« previous php.bugs (#200386) next »