You cannot have two classes with the same name, since PHP would not know which one is being referred to when creating a new object. To solve this issue, PHP allows the use of namespaces.
Author: BrainBell
The Closure Class
A closure is an anonymous function, but an anonymous function is not a closure.
OOP Traits
A trait defines methods and properties intended to be used by multiple classes. The structure of a trait is the same as a class, except that it’s declared using the keyword trait instead of class. You import traits into a class definition with the use keyword.
OOP Composition and Aggregation
In the composition design pattern an object creates another object. Aggregation occurs when an object is composed of multiple objects.
OOP Polymorphism
Polymorphism is a design pattern in which classes have different functionality while sharing a common interface.
Comparing Objects
PHP provides several comparison operators that allow you to compare two values, resulting in either true or false. To compare objects, we use == and === operators.
Object Cloning
How to use the clone keyword to clone an object and use the __clone magic method to customize the behavior of the cloning process.
Abstract Classes vs. Interfaces
In this tutorial, we explain the difference between abstract classes and interfaces.
OOP Interfaces
An interface is very similar to an abstract class, but it has no properties and cannot define how methods are to be implemented. Instead, it is simply a list of methods that must be implemented.
OOP Abstract Classes and Methods
An abstract class provides a partial implementation that other classes can build upon. In addition to normal class members, it may contain incomplete methods that must be implemented in child classes.