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: Access control

Solution: Access control - PHP Tutorial

From the course: PHP: Object-Oriented Programming

Solution: Access control

(upbeat music) - [Instructor] I hope that you were able to complete the Access Control Challenge assignment. Let me show you my solution. The first part of the challenge was simply to copy the class definition for Bicycle that we had created in challenge_01.php. So I created a new file called challenge_03.php, I went to challenge_01.php, and I just grabbed that class definition, pasted it over here. The second part was to go through and look at all of the properties and methods and consider what visibility modifiers we should put in front of them. Because it's the best practice to always add visibility modifiers. Before, we had simply put var in front of each of these properties. We don't want to do that. We don't want to just have function to define each of our methods. We want to have a visibility modifier in every case. I decided that all of the existing properties and methods needed to be public, so I put…

Contents