Magento Imagine Awards 2019 Finalist

PHP Short tags: Are they good or bad?

Recently in the office chatroom we had a discussion regarding PHP’s short tags:


For those that don’t know what PHP Short Tags are, they are basically a shorthand for PHP’s echo or print statements:

[pyg language=”php”]
// Example of PHP’s short Codes
$name = ‘Andrew’;
$employer = ‘’;

Now consider the following HTML snippet:

[pyg language=”html”]


How are you enjoying life at ?

Pretty clear and concise huh? This is straightforward and easy to use, but what if you have many of these statements to output on a page? This is what PHP Short Tags were created for. Using syntax similar to short tags found in Microsoft Active Server Pages (ASP) or Java Server Pages (JSP) you can do the same with less typing:

[pyg language=”html”]


How are you enjoing life at ?

Personally I don’t like using PHP Short Tags. Firstly, they can actually be disabled in PHP’s config file, php.ini which means you can’t guarantee code portability. Secondly I think it makes some code unreadable. Consider the following:

[pyg language=”html”]


And compare the readability with this:

[pyg language=”html”]


I personally think the second example is much easier to read. As Aaron pointed out there are valid reasons to use PHP Short Tags. New developers coming from ASP or JSP would understand them easier and they are marginally faster to parse.

What do you think? Are PHP Short Tags a good or bad thing?

Subscribe via email

Sign up to get notifications of new posts by email.

Share this article

Posted in Development

Other posts you might like

Last Saturday 12th November myself and eight of my teammates donned our iWeb hoodies, packed our rain macs and headed…

ModGrind is a tool that we’ve developed internally at iWeb for profiling Magento sites. We use it to diagnose speed…

Magento has been under a lot criticism for it’s Magento Connect Manager requiring “chmod 777” permissions across your files and…

Call us on 01785 279920

Our friendly Magento experts are happy to answer your questions.

Follow us!

Get the latest eCommerce news, reviews and expert advice in your inbox.

To find out more about how we use your data, read our Privacy Policy