At 18:02 23.02.2003, michel 'ziobudda' morelli wrote:
Il dom, 2003-02-23 alle 17:32, Marcus Börger ha scritto:
> You can do the following:
> class derived extends base {
> function __construct() {
> parent::__construct();
> echo "derived::__construct()\n";
> }
>
I know know.
What I want to know is why the base::__construct() is called (in
automatic) only when derived::__constuct() is missing.
I think that or the base::__construct() is always in automatic called or
it is never called (always in automatic).
In ZE2 each class has a constructor. That constructor can be overwritten
by writing a method named "__construct". So far so good. Unlike other
languages, C++ for one, PHP does not call any inherited constructors
automatically, C++ calls the default constructor if not set explicitly. But
PHP inherits the constructor if it is not redeclared/overwritten. Therfor
if the base has a constructor and the derived has not the inherited (the
one from base) is called.
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
----------------------------------------------------------------------
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php