I’ve seen quite a few instances of people asking when and where to use PHP’s alternative syntax for control structures and if you don’t know what I’m referring to, check out the PHP documentation for an outline.
There’s no hard and fast rule for when to use the alternate syntax but personally, I much prefer the alternative syntax for template use. I never use it in blocks of PHP code but I always use it when I’m writing templates. I just find it a whole lot more readable than trying to find the closing brace wrapped in PHP tags in amongst a bunch of HTML markup.
Here is a look at what a basic WordPress template looks like when using the alternative syntax:
The endif
and endwhile
tags are just so much clearer in amongst template code.