Classes and Objects

Classes are blueprints. They define what an object can store (properties) and what it can do (methods).

Objects are the real instances created from that blueprint. Multiple objects can be created from the same class, and they all share the same structure, but each one holds its own values.

Methods are functions that live inside the class. They’re used to group behavior that should belong to the object itself, like setting or displaying its own data.

Inside a method, $this refers to the current object, so it’s how the object reads and updates its own properties. This is what makes a “setter” style method work: values get passed in, and the object assigns them to itself.

instanceof is a simple check to confirm whether a variable is an instance of a specific class.