JObject/JObject
From Joomla! Documentation
< JObject(Difference between revisions)
(New page: A hack to support __construct() on PHP 4. In PHP 5 a method becomes a constructor when it has name "__construct". In PHP 4 constructors have the same name as the class. But it will be con...) |
|||
| Line 1: | Line 1: | ||
| + | {{review}} | ||
A hack to support __construct() on PHP 4. | A hack to support __construct() on PHP 4. | ||
Latest revision as of 19:09, 18 December 2008
| This is a article which: needs review. You can help the Joomla! Documentation Wiki by contributing to it. More pages that need help similar to this one are here. If you feel the need is satistified, please remove this notice. While actively editing, consider adding {{inuse}} to reduce edit conflicts. |
A hack to support __construct() on PHP 4.
In PHP 5 a method becomes a constructor when it has name "__construct". In PHP 4 constructors have the same name as the class. But it will be convenient to name constructors in the same way independently of PHP version.
This method is a hack to support __construct() on PHP 4. It works because it has the same name as the class. Also it will be invoked when a child class has no constructor. When invoked it calls method $this->__construct() and pass its arguments to it. So you can use JObject as a base class for your classes and name constructors as "__construct".