The CodeIgniter End-of-File Comment Convention
From the CodeIgniter User Guide:
The PHP closing tag on a PHP document ?> is optional to the PHP parser. However, if used, any whitespace following the closing tag, whether introduced by the developer, user, or an FTP application, can cause unwanted output, PHP errors, or if the latter are suppressed, blank pages. For this reason, all PHP files should OMIT the closing PHP tag, and instead use a comment block to mark the end of file and it's location relative to the application root. This allows you to still identify a file as being complete and not truncated.
INCORRECT:
<?php
echo "Here's my code!";
?>
CORRECT:
<?php
echo "Here's my code!";
/* End of file myfile.php */
/* Location: ./system/modules/mymodule/myfile.php */
I agree that it is a good idea to omit the PHP closing tag, and also to mark the end of file with a comment. But I think it is a bad idea to embed the name and location of the file in that comment. This introduces an unnecessary dependency between the internal contents of a file and its name and location. It should be possible to rename or move a file without having to change its contents. Embedding the file name and location make this impossible. This is particularly ironic as one of the first operations that many people perform after installing CodeIgniter is to move the application directory up one level (see the CodeIgniter video tutorials by Jeffrey Way, for instance).
Reader Comments (1)