Re: Re: Class::__construct() vs. $this->__construct()

From: Date: Fri, 01 Apr 2005 16:19:58 +0000
Subject: Re: Re: Class::__construct() vs. $this->__construct()
References: 1 2 3 4 5  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-37044@lists.php.net to get a copy of this message
Hi, Joe Stump schrieb:
I only asked because I saw XML_Parser was calling XML_Parser::__construct() from function XML_Parser(). I though $this->__construct() would be safer. A bug possibly?
Imagine this class: MyParser extends XML_Parser {
     function MyParser()
     {
       $this->__construct();
     }
     function __construct()
     {
       ....
       parent::XML_Parser();
     }
} If you create a new instance and XML_Parser would be using $this->__construct(), it would call MyParser::__construct() instead of XML_Parser::__construct(). That's why XML_Parser is specifying the class name. Otherwise inheritance is no longer possible or will totally break scripts. Stephan -- http://www.php-tools.net http://www.schst.net http://pear.php.net

« previous php.pear.dev (#37044) next »