In this series, we’ll continue to build the spaceship app that we’ve started in Introduction to Object-Oriented PHP and Object-Oriented PHP Part 2. In this series we will explore the inheritance in PHP through abstract classes and methods. We'll also take a look at how to create and implement interfaces.
In this series, we’ll continue to build the spaceship app that we’ve started in Introduction to Object-Oriented PHP and Object-Oriented PHP Part 2. In this tutorial, I’ll show you how to use the
extends keyword in PHP so that you can use it to inherit properties and methods from another
In this tutorial, I will show you how to override a method that you’ve inherited from another class. By having two classes we are starting to shape the different behaviors and properties of each, while still keeping most things in common and not duplicated.
In this tutorial, I will show you the difference between public, private, and protected methods or properties in PHP classes. By the end of this lesson you will learn how to make things private at first, protected once you need to access them in a subclass, and public when you need to use it outside of its class and subclass.
In this tutorial, I will show you the power of abstract classes and how you can enforce subclasses to define certain functions. In this way, you can share logic but for things that are really specific to subclasses, you can force them to define certain functions, but with the specific logic required.
In this tutorial, I will show you how to handle new requirements for data storage by creating two smaller abstract classes out of our original data storage class. By creating these new abstract classes, we can build more flexibility into our code.
Now that we have created new abstract classes, we need to load and utilize them in our code. In this tutorial, I will show you how we can refactor our code to make use of our new abstract data loading classes.
We have an abstract class with methods that we require, but there’s no logic in these abstract methods. This is a perfect opportunity to use interfaces. In this tutorial, I will show you how to create and implement Interfaces. I will also explain how interfaces are useful when you will be sharing your code. But even if you’re not creating interfaces to share, chances are, if you’re using open source code — and definitely in Drupal — you will need to know how to implement interfaces.