Jump to content

autoload extender classes


boby

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/71055-autoload-extender-classes/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.