I want to replace a class which is loaded in main project by $addon= new Add_On
; the Add_On class has the structure I like but I want to replace all its details.
I can comment out the $addon = new Add_on
in main project and load my own , but I don't want to modify the main project's code directly. How can I replace this class?
Add a comment
|
3 Answers
First, rename the Add_On class to something else, like Base_Add_On, then append this to the file where it is defined:
class Add_On extends Base_Add_On
{
// your custom replacements here
}
if you can make change to auto_load or spl_auto_load function in your project ,you will replace these classes with your own.
Create a new class extending Add_On class:
Class Replace_Add_On extends Add_On {
// Override any functions or add new ones
}