Re: Class constructor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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@xxxxxxxxxxxxxxxxxx | http://www.synchromedia.co.uk

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux