Re: [PHP4BETA] OOP issue

From: Date: Mon, 15 Nov 1999 18:08:00 +0000
Subject: Re: [PHP4BETA] OOP issue
References: 1 2 3 4 5 6 7  Groups: php.version4 
Request: Send a blank email to php-version4+get-6264@lists.php.net to get a copy of this message
Christian Schneider wrote: > Hmm... As a work-around you could have a method init() doing all the > work and simply call it from your constructor. Which is what I do at the moment. Still I get the support calls from people who are deriving their classes from mine and forget to include a constructor or don't call the init() method. For example, PHPLIB CVS contains a menu class. To use Menu, you just have to provide a menu structure in two arrays, describing the hierarchy of items and the attributes of each item. You have to call setup() to initalize the class, though. If you derive MyMenu from Menu, you have to include class MyMenu extends Menu { var $urlmap = array(...); var $items = array(...); function MyMenu() { $this->setup(); } } The MyMenu() constructor must be included, although it is completely superflous. It only calls the real constructor. I cannot inherit the constructor. Often people create Menu classes or rename the provided example classes and forget to rename or create the constructor. All examples won't work in this case, which is just plain stupid and completely unnecessary. Kristian -- Kristian Köhntopp, NetUSE Kommunikationstechnologie GmbH Siemenswall, D-24107 Kiel, Germany, +49 431 386 436 00 Using PHP3? See our web development library at http://phplib.netuse.de/ (We have moved! Update your bookmarks!)

« previous php.version4 (#6264) next »