Interesting Php OOP facts:

  • You can over-ride methods by declaring the same method with same arguments.
  • You can prevent over-riding of methods by declaring it <final> in a parent class. Trying to do so generates a fatal error.
  • There is a concept called overloading - which could allow more arguments than the original method.
  • A function's name and arguments is called "signature".

Access Control:(think of concentric circles)

  • public: (the default if undeclared): any page/script/class where the class is present.
  • protected: the class and derived override classes
  • private: only the class declared within
  • If a class has a method that should only ever be called by the class itself, it should also be marked either protected or private.


Butch the dog is eating

Peppy the cat is eating

generic pet is eating

Butch the dog is sleeping

Peppy the cat is sleeping

generic pet is sleeping

Butch the dog is play override

Peppy the cat is overriding playing

generic pet is playing in the Pet Class.

Toggle Sidebar