tips icon image

EE Insider Tips
Sponsored by Mijingo's EE 2 Screencasts

ExpressionEngine mini-howtos created by the EE Insider community.

Close PHP tags in your templates

User's avatar
  • Posted by johndwells
  • June 01, 2009
  • 2 people have found this tip helpful.

If you’ve taken the time to learn some of PHP’s best coding practices, you may have come across the technique of omitting the PHP closing tag to avoid unintentional output of white space. For example, the Zend Framework’s coding standard has adopted this, explaining that:

“For files that contain only PHP code, the closing tag (”?>”) is never permitted. It is not required by PHP, and omitting it prevents the accidental injection of trailing white space into the response.”

Well, ExpressionEngine developers must ignore this advice: where a template file is set to allow PHP processing, the EE template engine needs the closing tag even when the template is all PHP; if omitted, a parse error is thrown by eval():

Parse errorsyntax errorunexpected '<' in /ee/core/core.functions.php(637) : eval()'d code on line XX 

Add Your Comment?

You must have an EE Insider account to post comments on Insider Tips. It's fast, easy and hassle-free.

Sign up now (or login).

Search EE Insider Tips
Sponsored By