From the course: Learning PHP

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

What are objects and classes?

What are objects and classes? - PHP Tutorial

From the course: Learning PHP

Start my 1-month free trial

What are objects and classes?

- [Instructor] Functions are a great way to have consistency throughout your code base. And you can reuse useful code. Another way to do that is with classes. A class is a way of grouping variables and functions together as a single referenceable unit. The powerful part of classes is you can have more than one as long as you name them differently. The different instantiations or versions of these classes are called objects. And the benefit is that you can have a single set of variables and functions and based on the object, reference them. PHP has many built-in functions but we can also write our own. So if you have a Person class, you can use it to create two Person objects, Alice and Bob. They'll have the same variables and functions available to them but the information will be different. You can think of classes as the mold for a toy. Then each individual toy with different color plastic and paint are the objects.…

Contents