JObject/JObject

From Joomla! Documentation
< JObject(Difference between revisions)
Jump to: navigation, search
(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


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".

[edit] See also

Personal tools
Namespaces

Variants
Actions
Navigation
Joomla! Sites
Toolbox