From the course: PHP: Object-Oriented Programming

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Compare objects

Compare objects

- [Instructor] In this movie, we'll learn how PHP compares objects. There are two ways that we can perform comparisons. The first is using the simple comparison operator, equals equals. That's what you're probably used to most of the time. There's also a stricter version of that, which is the identity operator, and that's a triple equal sign. It goes just a little bit further and makes sure that things don't just appear to be the same, but they are actually the same. Let me show you how that plays out when we're working with objects. So with objects, the comparison operator will compare the objects properties. So if the class is the same and the property values are the same, then they will be considered equal. So if we have variables that reference the exact same instance, or if they reference two different instances, but which both have matching properties so that they seem to be identical, then it'll return…

Contents