They're basically the same thing, however, you can only use __construct in
PHP5.

--
itoctopus - http://www.itoctopus.com
"John Comerford" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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

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

Reply via email to