PHP a lot of else if another approach? -
Here's my code, I want to ask, what's the best way to do this? I would like more "if" option and I'm concerned about performance
if ($ _ GET ['start'] === 'yes') {} else if ( $ _GET ['start'] === 'Dida') {} And if ($ _GET ['start'] === 'bira') {} And if ($ _GET ['start'] === 'EIMA Otherwise if ($ _GET ['start'] === 'ABA') {}
You should use the switch statement instead. Creating a switch is more easily translated into a leap (or branch) table In case that the labels are closed simultaneously, the switch statement can make more efficient from if-else The jump keeps a bunch of instructions and then adds value to the program counter. It changes the sequence of comparison instructions with an addition operation. - @ Judge Megarden $ start = $ _GET ['start']; Switch (starting $): case 'yeg': // break something; Case 'deda': // Break something; Case 'Bira': // Something break; The case 'eima': // break something; Case 'ABA': // Break something; Endswitch;
Comments
Post a Comment