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 tags, then go to your config
file, and alter the following line to TRUE
:
$config['rewrite_short_tags'] = FALSE;
CI will then rewrite short tags to the normal form before it sends them to the server. However, if there is a PHP error...