How do you decide between using a switch or an if statement?
Say I have a file admin.php that has four administration modes: user, group, type and definition. A few common requests may look like:
admin.php?mode=user&action=modify&user_id=143
admin.php?mode=type&action=create
In admin.php I have an if...else control structure for the modes:
if($gForm['mode'] == 'user') {
do stuff....
} elseif($gForm['mode'] == 'group') {
do stuff....
} elseif($gForm['mode'] == 'type') {
Would there be any benefit from using a switch($gForm['mode']) statement instead of the if..else type of structure? I can only iamgine there might be a difference in speed, aside from that I'm not sure what kind of benefit you would have either way.