SPACE.LA
← blog

PHP Short Tags

Short tags aren't going anywhere, so why not use them! Short tags are best used in template files in frameworks like Zend Framework.

These are short tags

<? $items = array('apple','pie','bacon'); ?> <? foreach ($items as $item) : ?> <? if ($item == 'bacon') : ?> <?=$item?> <? else : ?> <?=$item?> <? endif ; ?> <?endforeach ; ?>

Enable in php.ini

short_open_tag = On

Enable in .htaccess

php_flag short_open_tags on

Hooray for less typing!