Not a support request really, but out of curiosity why are the php tags at the end of all the mothership .tpl.php files open (example <?php } )? Are there any possible cons to leaving them open?

Comments

nightowl77’s picture

Status: Active » Closed (fixed)

This is not something related to mothership - it is the "drupal way". You'll see that all modules, all themes, all core Drupal files never end with the php closing tag.

The reason for this is simple: if you have a closing tag and accidently press enter after that closing tag you will have one empty line. The webserver sends that empty line to the client the moment it parses it, and most of the time that happens before the session cookie or other header information was sent. The result - you get an ugly error message saying something like "Warning: header information could not be sent, output started at line xxx of file yyy"

Since php automatically considers the end of a file as a php closing tag, it is much better to just never put it there - you can then accidently add as many newlines to the end of the file without it affecting anything.

RobW’s picture

Thanks very much for taking the time to answer. That was informative and will probably save me some headaches down the road.