note 39185 deleted from control-structures.switch by crell
| From: | crell@php.net | Date: | Mon, 27 Jun 2022 20:58:39 +0000 |
| Subject: | note 39185 deleted from control-structures.switch by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218643@lists.php.net to get a copy of this message | ||
Note Submitter: php dot net dot 1 at yogelements dot com
----
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
?>