To PHP Short Tag or not to PHP Short Tag?

Here’s a compact “flow chart” to make a decision. If you can answer any of the questions with “yes”, you shouldn’t use short tags (<?):

  • Are you creating a theme for other people to use?
  • Are you building a site you don’t fully control the hosting of?
  • Are you working in a team and don’t want to add another rule to your coding styleguide?
  • Do you need to have XML in your templates?

I generally don’t recommend using short tags as the advantages don’t often outweigh the disadvantages. But I do recommend using the short echo tags (<?=), they are very awesome and quite easy to understand.

4 Likes