Best Practice for PHP

That’s question is only relevant, because WordPress use a mix from a coding language and layout language. If you would use a template language, syntax, than is this topic not relevant.
But to your question. If you use your example source for a Theme, much more layout language like html, then I prefer the first one – it is much more readable for designer and users, there must read the markup. It is easier to create an overview about the markup, have you the open and closing tags etc.

For the include in plugins, code with more logic and flow is the second example easier to implement. The main topic is php, not markup and this should it visible in the source. That’s also a point to think about to exclude this markup in template files and separate the markup from the logic.

Leave a Comment

error code: 523