Solution Review: Access Modifiers
Explore how to implement and manage PHP access modifiers in object-oriented programming. Understand using private properties with public getter and setter methods, and test these concepts by building a User class that securely handles data access.
We'll cover the following...
We'll cover the following...
Solution
Explanation
- Line 2: We write the
Userclass with the$firstNameprivate property. - Line 5: We add the public setter method