boby Posted September 28, 2007 Share Posted September 28, 2007 Hello guys! I have a probably simple question for you... Let's say I have these two classes: class core { function core() { //do stuff here } } class parser extends core { function parser() { //do other stuff here } } Can I somehow tell the "core" class when it runs the constructor to load inside it (parent) all available extender classes? So if someone writes a new class to extend the "core" it should be automatically loaded, without needing me to load it in the constructor of the parent or to initialize with: $sub = new $subclassX; I am looking into something like adding a few classes that I need into the "core" class, but more if I have let's say a function "getID()" in the "core" and someone wants to use a different method, to easy load a new class with a new function that will do it the new way. Is this possible? Thank you for any help. Boby Quote Link to comment https://forums.phpfreaks.com/topic/71055-autoload-extender-classes/ Share on other sites More sharing options...
steelmanronald06 Posted September 30, 2007 Share Posted September 30, 2007 you want to call functions and variables from the parent class in the child class without initiating the parent class? If so, you can do stuff like: parent::core(); parent::function(); get what i'm saying? http://us2.php.net/manual/en/language.oop5.paamayim-nekudotayim.php I think that might help Quote Link to comment https://forums.phpfreaks.com/topic/71055-autoload-extender-classes/#findComment-358384 Share on other sites More sharing options...
Ninjakreborn Posted September 30, 2007 Share Posted September 30, 2007 Or if not then you basically answered your own question. in the constructor you would just instantiate each extension into a variable and you can have access to it that way. Look at cake/code ignitor because they have a nice way of doing it. Quote Link to comment https://forums.phpfreaks.com/topic/71055-autoload-extender-classes/#findComment-358391 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.