note 93843 deleted from control-structures.switch by danbrown
| From: | danbrown@php.net | Date: | Fri, 02 Oct 2009 19:34:22 +0000 |
| Subject: | note 93843 deleted from control-structures.switch by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161239@lists.php.net to get a copy of this message | ||
Note Submitter: jed at jkoops dot com
----
Note: the suggestion from August 24, 2009 ("you can also use operators in each case
statement") is incorrect. If you use an operator as in the example given, the program flow
will ALWAYS go through that case statement ("Do something here"), no matter what the value
of $Mode is. Not very useful. To use an operator you'll need to specify a complete condition
as in the second case statement below:
<?php
switch($Mode)
{
case "one":
// First mode
break;
case ($Mode == "open" || $Mode == "view"):
// Do open or view
break;
default:
echo 'Invalid mode';
break;
}
?>