Re: _Construct question
| From: | itoctopus | Date: | Wed, 21 Mar 2007 13:06:14 +0000 |
| Subject: | Re: _Construct question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-251052@lists.php.net to get a copy of this message | ||
They're basically the same thing, however, you can only use __construct in
PHP5.
--
itoctopus - http://www.itoctopus.com
"John Comerford" <johnc@optionsystems.com.au> wrote in message
news:46007391.6040509@styleman.com.au...
> Hi Folks,
>
> I am still pretty new to PHP and I have a question regarding classes and
> using _construct. Up until now I have been creating my classes as
follows:
>
> class test1 {
> var $name;
> function test1($pName) {
> $this->name = $pName;
> }
> }
>
> So I when I create a new class I can assign 'name' by doing '$t1 = new
> test1("test1");'
>
> As part of another thread I noticed the _construct function which (if I
> am correct) does more or less the same thing:
>
> class test2 {
> var $name;
> function _construct($pName) {
> $this->name = $pName;
> }
> }
>
> I have fished around a bit and cannot find why one might be better than
> the other. The only thing I can think is that maybe you need to use
> _construct to be able to use "extends" ?
>
> Is this the case ? What is the advantage/disadvantage of using
> _construct as opposed to using a function with the classname ?
>
> Thanks,
> JC