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;
I belive the compiler will turn them into very similar, or maybe even identical code at the end of the day.
Unless you're doing something weird, don't try and do the optimisation for the compiler.
Also, developer time is generally more important than runtime (with the exception of games), so it'sbbetter to make its more readable and maintainable.