Zoiets bijvoorbeeld (CakePHP AppController):
<?php
App::uses('Controller', 'Controller');
class AppController extends Controller
{
public $helpers = array('Js' => 'MooTools', 'Time', 'Html', 'Session', 'Form');
public $components = array('Session');
public function beforeFilter ()
{
$this->theme = Configure::read('Site.theme');
}
}
?>
Voor de duidelijkheid: normaal heeft dit bestand geen ?>, maar ik moest het in dit geval toevoegen, anders werkt de formatting niet op het forum.
Het was me eerlijk gezegd in eerste instantie niet opgevallen, maar het is gewoon valid. Sterker nog, zelfs Zend raad je aan om php-bestanden niet te sluiten met een ?>
Zend Manual
The closing tag of a PHP block at the end of a file is optional, and in some cases omitting it is helpful when using include() or require(), so unwanted whitespace will not occur at the end of files, and you will still be able to add headers to the response later. It is also handy if you use output buffering, and would not like to see added unwanted whitespace at the end of the parts generated by the included files.
Nog sterker: Zend verbiedt het gebruik van de sluitingstag bij php-only bestanden.
Zend reference guide
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.
http://framework.zend.com/manual/en/coding-standard.php-file-formatting.html
Toch zie ik op bepaalde plekken hevige discussies over waarom het wel en niet goed zou zijn. Ik was benieuwd hoe men er op PHPHulp over dacht.