Alternate to if else use switch statement
If you execute the if else statements which multiple conditionsits go throw each condition and check with those condition is matching. For example you written if else condition
if($i == 15) elseif($i == 25) elseif($i == 35) elseif($i == 45) elseif($i == 55) elseYou want to match 45 value,while executing this above script variable matches with each if and else condition
and finally matches 45 value, so condition executed above with unmatched value then it took the execution time.
Alternative Switch statement
Suppose you are using the swithc statement for the above case. Exampleswitch($i) { case 15: break; case 25: break; case 35: break; case 45: break; case 55: break; }In this above switch statement, if the $i values was 45 then execute 45 matched values and go through the further process.
No comments:
Post a Comment