Confused over some IF syntax...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Wolf_22
Forum Contributor
Posts: 159
Joined: Fri Dec 26, 2008 9:43 pm

Confused over some IF syntax...

Post 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?
User avatar
turbolemon
Forum Commoner
Posts: 70
Joined: Tue Jul 14, 2009 6:45 am
Location: Preston, UK

Re: Confused over some IF syntax...

Post 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..
Wolf_22
Forum Contributor
Posts: 159
Joined: Fri Dec 26, 2008 9:43 pm

Re: Confused over some IF syntax...

Post by Wolf_22 »

That's what I was thinking. Thanks for the info Michael. :)
Post Reply