Re: Why parent::construct not called?

From: Date: Sun, 23 Feb 2003 16:32:49 +0000
Subject: Re: Why parent::construct not called?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-94492@lists.php.net to get a copy of this message
At 16:46 23.02.2003, michel 'ziobudda' morelli wrote:
Hi, why if I have class B extends A { } the only way to call in automatic the A::__construct() is to not write the B::__construct() ? Ok, this is the design of PHP. But why ?
You can do the following: class base {
        function __construct() {
                echo "base::__construct()\n";
        }
        function __destruct() {
                echo "base::__destruct()\n";
        }
} class derived extends base {
        function __construct() {
                parent::__construct();
                echo "derived::__construct()\n";
        }
        function __destruct() {
                parent::__destruct();
                echo "derived::__destruct()\n";
        }
} See: http://marcus-boerger.de/php/ext/ze2/ctor_dtor_inheritance.phpt.txt regards marcus -- ---------------------------------------------------------------------- Marcus Börger - Looking for all sorts of freelance work - just ask... Did i help you? Consider a gift: http://www.amazon.de/exec/obidos/wishlist/ho722v0rg1u0 ----------------------------------------------------------------------

« previous php.dev (#94492) next »