Which is the better and fastest methods : if or switch ?
if(x==1){
echo \"hi\";
} else if (x==2){
echo \"bye\";
}
switch(x){
case 1
...
break;
General rule is use switch whenever the number of conditions is greater than 3 (for readability).
if / else if / else is more flexible (hence better), but switch is slightly faster because it just computes the condition once and then checks for the output, while if has to do this every time.
EDIT: Seems like switch is slower than if after all, I could swear this was not the case...