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.

Define a class

Define a class

- [Instructor] In this movie, we will learn how to define a class in PHP. A class provides the definition of an object. It describes it. And it serves as a template for creating new objects. Every class definition begins with the keyword class followed by the class name. Then you have curly braces that surround the class definition. In the first example, the class is called Person. In the second, it's ProductImage. There are a few best practices that we should observe when declaring classes. The first is that you want to capitalize and camelcase the class names. Camelcase means that you use uppercase for the first letter and then the other words would also be capitalized as well. ProductImage was an example of that on the last slide, both the P and the I are capitalized. Class names should also use singular nouns. Don't use plurals, because we're defining what a single object would look like. It's also a best practice…

Contents