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.
Class properties - PHP Tutorial
From the course: PHP: Object-Oriented Programming
Class properties
- [Instructor] In this movie we're going to learn how to add properties to our class definitions. Properties are simply variables to hold object values. These are also frequently referred to as attributes, class variables, or instance variables. And you'll hear these terms used interchangeably all the time. They mean the same thing. They're even used interchangeably inside the PHP documentation. So don't be confused if you see it called properties one place and attributes somewhere else. The way that we define properties is with the var keyword followed by the variable name that we want to use. And our variable name follows all the normal variable naming rules. We also have the ability to set an initial default value for each property. Let's see an example. Here. I have a class Person and inside there are four properties being defined. First name, last name, employed, and country. You can see that all of them…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.