There is always some tension between passing parameters around (individually or in immutable types of aggregates that actually do not exist in PHP) and storing them somewhere (be it class properties, global variables, etc.). One of the advantages of OOP is that you can save state in objects and benefit from encapsulation (prevents a lot of accidental data overwriting), while avoiding pollution of symbol tables with variables. Using these mutable objects has its own problems, especially if we move on to multi-threaded programming, but this is less true for PHP.
In your particular case, I think it would be better to keep the title in the object. As Siliko said, it seems to refer to page , and besides, you can do things like:
$page = new page; $page->setTitle("whatever"); ... function doStuff($page) { ... $page->showhead(); }
And then you do not need to pass $page along with the header.
Artefacto
source share