When to use the alternative PHP syntax
Ben Everard made a short video describing when he thinks it’s appropriate to use the alternative PHP syntax. He uses the example of his WordPress blog templates. He makes good points, but primarily he notes that it allows for a descriptive method for knowing when loops start and stop, because of the
His explanation makes sense. But you could also use “terminating comments” to achieve a similar visual, as Tom McFarlin explains.
Personally, I enjoy using the alternative sytax Ben describes for templates where I’m alternating a good bit between PHP and HTML. I prefer a traditional syntax with terminating contents on closing brackets when I’m primarily writing PHP, like in a functions file or a plugin. But that’s just my personal preference.
Most importantly though, you should just be sure to use good indentation (and plenty of good whitespace in my opinion), follow the WordPress coding standards, and comment your code as much as possible.
A… video? To show code? I’m clicking the link only because I want to see how someone managed not to make a joke with that 🙂
Comments are closed.