Tag Archives: tutorial

In this tutorial, you’ll learn how to create interfaces and why you should use them. They are very similar to abstract classes. At the end of this tutorial, we’ll discuss the differences and the benefits of each one. We’ll be creating something similar to our recipe and cookie class in our abstraction tutorial. Creating Interfaces Create a file called index.php …

Today, we’ll be discussing what abstract classes are and how we could use them. There will be times where you’ll create a class that you don’t want anyone to use directly, but instead extend it. Let’s take a closer look at this Creating Abstract Classes We’re going to deviate from our Pet class for a bit. Mostly because we don’t …

Let’s learn how to create static methods and properties. Anything that’s static is basically something that can be accessed without needing an instantiation of the class. You also have the advantage of having a value that is consistent through each instance of the class. Let’s take a look at this. Creating Static Properties Inside our Pet Class, add this bit of …

Constants are variables that don’t change value during the lifetime of a program. Defining constants in classes are a bit different than defining constants outside of a class. Defining Constants In our CanadianPet class, add this bit of code. [crayon-5ce964f3e7fcd906256198/] To define a constant, we use the const keyword. We then follow it by the name of the constant and …

The scope resolution operator may sound intimidating, but it’s actually quite simple to use. What it basically does is it allows you to access static, constant, or overridden methods and properties of a class. We haven’t discussed static and constant properties and methods yet. We will soon in a another tutorial, but for now, we can use it to access …

Let’s talk about inheritance. We’ve talked about how to extend a class and covered encapsulation. Inheritance is when a class extends another class and inherits the properties and methods of that class. The main advantage to this is the ability to use a parent class and modify it for a special use without actually modifying the actual class itself. You …

It’s always good practice to have things set up when someone creates an instance of your class instead of calling a bunch of functions to do so. Users should only have to call set methods when they need to update or change some properties in your class. The constructor method is the perfect solution to setting up your class for …

Encapsulation may seem like an intimidating topic, but it’s actually quite simple. Object oriented programming is based on 3 principles which are encapsulation, inheritance, and polymorphism. In this tutorial, we’ll be talking about encapsulation and why it’s important to understand this principle. We’ll talk about the other 2 in future tutorials. What is encapsulation? So, what is the meaning behind …

Let’s create our first real plugin. We’ll be talking about WordPress action hooks and what hooks are. WordPress Hooking System WordPress has a very special hooking system that is the basis for creating plugins. There are two types of hooks, actions and filters. We’ll only be discussing WordPress action hooks for this lesson. An event is when something happens. This …