note 86408 deleted from control-structures.switch by cmb

From: Date: Sun, 21 Apr 2019 11:55:32 +0000
Subject: note 86408 deleted from control-structures.switch by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-210651@lists.php.net to get a copy of this message
Note Submitter: ben dot lancaster at holler dot co dot uk ---- Following on from bensphpnetemail at supernaut dot org's post, it would seem that 'continue' doesn't really continue at all. Consider the following: <?php $foo = 'bar'; $bar = true; switch($foo) { case 'bar': if($bar) { continue; } echo '$bar is false'; break; case 'bar': case 'foo': echo '$bar is true, or $foo is foo'; break; default: echo "You shouldnt ever get here"; break; } ?> I would expect the above to output "$bar is true, or $foo is foo", but it doesn't output anything. The continue statement acts as a break and stops evaluating the rest of the matching cases. Instead, you should issue a 'break' statement conditionally to achieve the desired result.

« previous php.notes (#210651) next »