The topic of interfaces. An interface resembles an abstract class but there are a few differences. With the abstract class, you can create method declarations and implemented methods. Child classes can then inherit an abstract class and override or implement its methods. With an interface, you can only define the functionality. You can’t actually implement anything.
The biggest difference is that a child class can only extend one abstract class but it can implement multiple interfaces. You will hear the term contract when talking about interfaces meaning that once you implement it, you are obligated to define each method that was declared inside the interface.
Our Mammal class is a perfect example of an abstract class. There are certain methods that all mammals share, and do it the same way, so it’s a good idea to actually implement those methods there. I would argue that the Animal class makes a good candidate for an interface. Why? Because although all animals share certain similar traits, they each differ based on the animal.
So, you should force child classes to implement those methods. Interfaces begin with the keyword interface and the methods inside the interface are all abstract. You don’t have to use the abstract keyword. To implement the interface, you use the implements keyword, not the extends keyword.
Read the full article on my website
https://www.dinocajic.com/php-interface/
Code for this tutorial
https://github.com/dinocajic/php-7-yo...
Full Code
https://github.com/dinocajic/php-7-yo...
PHP Playlist
• PHP Tutorial
--
Dino Cajic
Author and Head of IT
Homepage: https://www.dinocajic.com
GitHub: https://github.com/dinocajic
Medium: / dinocajic
Instagram: / think.dino
LinkedIn: / dinocajic
Twitter: / dino_cajic
My Books
An Illustrative Introduction to Algorithms
https://www.amazon.com/dp/1686863268
Laravel Excel: Using Laravel to Import Data
https://amzn.to/4925ylw
Code Along With Me - PHP: From Basic to Advanced PHP Techniques
https://amzn.to/3M6tlGN
Nesta página do site você pode assistir ao vídeo on-line Interface - PHP - P61 duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Dino Cajic 18 Junho 2020, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 182 vezes e gostou 4 espectadores. Boa visualização!