Page 1 of 1

Confused over some IF syntax...

Posted: Tue Sep 15, 2009 7:44 am
by Wolf_22
I have the following in my script:

Code: Select all

 
[b]<?php if([/b][i]stuff[/i][b]): ?>[/b]
[b]<?php elseif([/b][i]stuff[/i][b]): ?>[/b]
   <ul>
         [i]stuff[/i]
   </ul>
[b]<?php else: ?>[/b]
   <ul>
         [i]stuff[/i]
   </ul>
[b]<?php endif; ?>[/b]
 
In the above, I'm confused as to why someone would write an IF block only to make it proceed directly into an ELSEIF. Is this some sort of shortcut that some developers use to act as a "logic catch-all" or was this someone's blunder or laziness?

Re: Confused over some IF syntax...

Posted: Tue Sep 15, 2009 7:56 am
by turbolemon
There's no reasonable explanation, other than the previous developer had code there and subsequently removed it. You should be safe to move the elseif into the if..

Re: Confused over some IF syntax...

Posted: Tue Sep 15, 2009 8:04 am
by Wolf_22
That's what I was thinking. Thanks for the info Michael. :)