View Single Post
  #7 (permalink)  
Old 05-09-2008, 04:30 AM
senraj senraj is offline
D-Web Master
 
Join Date: Jul 2007
Posts: 418
senraj is on a distinguished road
Post Re: PHP Control Structures

Hi,

switch Statements

Statement
switch (expr){
case expr:
statement list
case expr:
statement list
...
default:
}

You can use the switch construct to elegantly replace certain lengthy if/elseif constructs. It is given an expression and compares it to all possible case expressions listed in its body. When here’s a successful match, the following code is executed, ignoring any further case lines (execution does not stop when the next case is reached). The match is done internally using the regular equality operator (==), not the identical operator (===). You can use the break statement to end execution and skip to the code following the switch construct.
Usually, break statements appear at the end of a case statement list, lthough it is not mandatory. If no case expression is met and the switch construct contains default, the default statement list is executed. Note that the default
__________________
Regards,
Senraj.A

Last edited by senraj : 05-09-2008 at 04:34 AM.
Reply With Quote