Extends a class within php, as described in more detail here. Basically is making a second class extended from the first class with either making amendments to some of the functions or adding some, this makes the second class the version 2 from the first class (version 1).
The extended class can still call the parent (version 1) class via the
syntax, which basically means, calling the parent class to do something, for example the parent class may setup the variables of a array whilst the extended version 2 class may sort them into alphabetical order.
Here some code that may make more sense.
HiFromMe(); $base->BaseFunction(); $extended = new ExtendedClass(); $extended->HiFromMe(); echo "\nYou can still call the base functions because you extended it"; $extended->BaseFunction(); echo "\nTo call from within a function"; $extended->CallBaseFunction(); ?> and the output would be...Hi from the base class Hi from base function Hi from the extended class You can still call the base functions because you extended it Hi from base function To call from within a function Calling base (parent) class Hi from base function
One thought on “Extends class”
Nice tutorial. But i want more…