Re: Re: _Construct question

From: Date: Thu, 22 Mar 2007 00:09:15 +0000
Subject: Re: Re: _Construct question
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-251058@lists.php.net to get a copy of this message
That's not true, running with v. 5.2.1: <?php class A {
    function A() {
        echo "works\n";
    }
} $a = new A(); ?> Outputs: works On Mar 21, 2007, at 8:06 AM, itoctopus wrote:
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
--PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
erik jones <erik@myemma.com> software developer 615-296-0838 emma(r)

« previous php.general (#251058) next »