Chapter 5: Object Types, Interfaces, and Unions
In this chapter, we're going to look specifically at object and class types.
Objects, like scalars, have types. Unlike scalars, though, a single object can be regarded as one of a potentially large number of types. Let's explore how this works.
We'll begin by looking at object type inheritance. Then, we are going to understand how object comparison works and the difference between identity (===
) and equality (==
) when it comes to objects.
Finally, in this chapter, we're going to look at the relationship between object variables and instances and look to understand the way that in PHP, objects are passed by reference by default.
The topics in this chapter are interdependent and so it is tricky to find the correct order to explain things. If this is all new to you, it might be useful to read through the chapter twice so that it all properly makes sense to you.
The following topics will be covered in this...