This is a question that I’ve pondered for a while. Which is more code-efficient? Which is more performance-efficient? Will a switch statement run quicker than many different if statements?
Take this for example:
Code:
if($_GET[‘do’] == ‘add’){
// code here
} elseif { ($_GET[‘do’] == ‘edit’){
// code here
} elseif { $_GET[‘do’] == ‘delete'{
// code here
} else {
// code here
}
Would the above if statement run better than:
Code:
switch($_GET[‘do’]){
case(‘add’):
// code here
break;
case(‘edit’):
// code here
break;
case(‘delete’):
// code here
break;
}
Thanks for any opinions.