Note that there are some explanatory texts on larger screens.

plurals
  1. POReal World Examples of Advanced OOP Features for PHP
    text
    copied!<p>I am trying to improve my knowledge of OOP in PHP and have been researching abstract classes and interfaces.</p> <p><strong>What I have learned</strong></p> <ul> <li>They are both classes that cannot be instantiated themselves but can olny be extended (implemented in the case of interfaces)</li> <li>Abstract classes provide methods and properties for other classes that extend them.</li> <li>If a class uses an abstract method then the class itself must also be abstract.</li> <li>If an abstract method is defined within an abstract class, all child classes must define the details of that method. Methods not defined as abstract can be used in the same way as normal methods.</li> <li>Interfaces define what methods a class that implements it must have. The functionality of the methods are not defined in the interface, the interface just offers a list of methods that must be included in the child class.</li> <li>An interface does not define any properties.</li> <li>Classes can implement as many interfaces as they want to but they must define a method for every one of the interfaces they implement</li> </ul> <p>I think that covers the basics. Please feel free to add to that if you think there's anything I have missed.</p> <p>What I would like to know is if there are any real world examples of implementation of these classes, especially the interface class. Does anyone know of any open source applications that use them that I can browse to better understand them and see where and when they are used effectively? I have come across book examples which use animals which fails to demonstrate the importance of these classes.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload