I am using same php page for different operation. So condition wise I am doing some actions
Which one showing good perfomance?
This one
if($catid){ .. some action }
if($sub_catid){ .. some action }
if($sub_sub_catid){ .. some action }
OR This one
if($catid){
.. some action
}else{
if($sub_catid){
.. some action
}else{
if($sub_sub_catid){
.. some action
}
}
}
First off, those two have very different meanings. The first one could allow every single statement to execute if all those variables were TRUE. The second one will “short-circuit” the first time it finds something TRUE.
What I think you’re looking for is:
Bonus points: more readable!