note 9867 deleted from control-structures.switch by cece
| From: | cece@php.net | Date: | Sun, 14 Nov 2004 13:44:31 +0000 |
| Subject: | note 9867 deleted from control-structures.switch by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-80506@lists.php.net to get a copy of this message | ||
Note Submitter: anthony at n dot o dot s dot p dot a dot m dot trams dot com
----
You can also use this form of switch:
<?switch ( $test )
case 'foo' :?>
<FONT face="verdana">Foo</FONT>
<?case 'bar' :?>
<FONT face="verdana">Bar</FONT>
<?default :?>
<FONT face="verdana">Default</FONT>
<?endswitch ;?>
If $text is foo, you get all three results. If $text is bar, you get the last two. If it's
neither, you get only the last one. Adding breaks would look like this:
<?switch ( $test ) :
case 'foo' :?>
<FONT face="verdana">Foo</FONT>
<?break ;?>
<?case 'bar' :?>
<FONT face="verdana">Bar</FONT>
<?default :?>
<?break ;?>
<FONT face="verdana">Default</FONT>
<?endswitch ;?>
or this:
<?switch ( $test ) :
case 'foo' :?>
<FONT face="verdana">Foo</FONT>
<?break ; case 'bar' :?>
<FONT face="verdana">Bar</FONT>
<?break ; default :?>
<FONT face="verdana">Default</FONT>
<?endswitch ;?>
It may look strange, but it really helps when you have blocks of HTML avoiding lines like:
<?}?>