Re: PHP4 and Constructor

From: Date: Thu, 04 Oct 2007 04:36:39 +0000
Subject: Re: PHP4 and Constructor
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-44134@lists.php.net to get a copy of this message
this is why for backwards compatibility with PHP 4 people usually do this. Note that if you use public/private/protected it probably will not work on PHP 4 <?php class Foo { function __construct($params) { $this->Foo($params); } function Foo($params) { // Actual Constructor } } ?> On 10/4/07, Jean Molliné <jmolline@gmail.com> wrote: > Hi, > In PHP4, the constructor has the same name as the class. > > class ClassName { > function ClassName() { > .... > } > } > > > T K a écrit : > > Hi, > > > > I would like to use constructor in PHP4, but how do you make a constructor? > > In PHP5, I do like > > > > class ClassName { > > function __construct() { > > .... > > } > > } > > > > But PHP4 doesn't have such a thing as __construct()... Reading the > > official manual didn't make me understood. Does this mean the very > > first function in class is always the constructor for the > > Class? > > > > Tek > > > > > -- Joseph Crawford Jr. Zend Certified Engineer http://www.josephcrawford.com/ 1-315-820-4244 codebowl@gmail.com

« previous php.db (#44134) next »