note 9867 modified in switch by ronabop

From: Date: Sun, 25 Feb 2001 00:39:06 +0000
Subject: note 9867 modified in switch by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-11536@lists.php.net to get a copy of this message
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: <?}?> http://www.php.net/manual/switch.php

« previous php.notes (#11536) next »