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.
Solution: Properties and methods - PHP Tutorial
From the course: PHP: Object-Oriented Programming
Solution: Properties and methods
(bright upbeat music) - [Instructor] I hope that you were able to complete our first challenge assignment. If not, follow along with me as I show you the solution that I came up with. So the first thing that I did was I created a new file inside our OOP sandbox directory called challenge_01.php. And I opened up some PHP tags and I started defining a class. The class was going to be for a bicycle object. So we're going to have instances of different bicycles. So it's going to be class Bicycle, singular with a capital B. That's the way we want to name our classes, singular nouns with capital letters. If we have more than one word together, we do camel case. Then I've got my curly braces and then I've got a list of the different properties that I want to declare. Brand, model, year, description and weight_kg, short for kilograms. Each one of those is just simply a variable with var as a keyword in front of it. For…
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.