note 39185 added to control-structures.switch

From: Date: Tue, 20 Jan 2004 03:39:29 +0000
Subject: note 39185 added to control-structures.switch
Groups: php.notes 
Request: Send a blank email to php-notes+get-63857@lists.php.net to get a copy of this message
Declaring a variable (actually an array) as static w/in a switch{} spun my wool for a while: don't: <? function ss() { switch ("bug") { case "bug" : static $test = "xyz"; break; default : static $test = "abc"; } echo $test; } ss(); //abc ?> do: <? function tt() { static $test; switch ("fix") { case "fix" : $test = "xyz"; break; default : $test = "abc"; } echo $test; } tt(); // xyz ?> ---- Manual Page -- http://www.php.net/manual/en/control-structures.switch.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39185 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39185&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39185&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#63857) next »