Actions

Difference between revisions of "JObject/JObject"

From Joomla! Documentation

(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 18:09, 18 December 2008

Copyedit.png
This Article Needs Your Help

This article is tagged because it NEEDS REVIEW. You can help the Joomla! Documentation Wiki by contributing to it.
More pages that need help similar to this one are here. NOTE-If you feel the need is satistified, please remove this notice.


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

See also