Long and short PHP syntax and other CodeIgniter style guidelines

Before we go on, a note about different forms of PHP syntax. The usual way to include a PHP "code island" in the midst of HTML code is like this:

<?php echo $somevariable ?>

However, CI also supports a shorter version:

<?=$somevariable?>

In this case, the external brackets delimiting the code island have lost the letters php (they are just <? ?>) and echo ( replaced by =). You can also use shorter syntax for if, for, foreach, and while loops.

It is preferable to stick to the standard format and it is also recommended in the CodeIgniter style guide. If you use the short format, note that some servers won't interpret the abbreviated format correctly. If you still wish to use the short ...

Get CodeIgniter 1.7 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.