Reputation: 1727
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?
Upvotes: 0
Views: 1734
Reputation: 789
Create a new class extending Add_On class:
Class Replace_Add_On extends Add_On {
// Override any functions or add new ones
}
Upvotes: -1
Reputation: 13
if you can make change to auto_load or spl_auto_load function in your project ,you will replace these classes with your own.
Upvotes: 0
Reputation: 20492
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
}
Upvotes: 2