Re: Class constructor
| From: | Marcus Bointon | Date: | Wed, 01 Feb 2006 12:26:37 +0000 |
| Subject: | Re: Class constructor | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-229616@lists.php.net to get a copy of this message | ||
On 31 Jan 2006, at 13:52, David Grant wrote:
Drop __construct, PHP5 will call Test() anyway. From http://uk.php.net/manual/en/language.oop5.decon.php: "For backwards compatibility, if PHP 5 cannot find a __construct() function for a given class, it will search for the old-style constructor function, by the name of the class."Sure, if you're planning on writing 'backwards' code for ever more... For maximum efficiency in PHP5, do it this way around: class test{ function Test(){ $this->__construct() //This will be called in PHP4 } function __construct(){ //This will be called in PHP5 } } Why penalise the platform you're intending to run it on? Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture marcus@synchromedia.co.uk | http://www.synchromedia.co.uk