Home > Article > Backend Development > A brief discussion on the scope of access modifiers private, protected, and public in PHP
1. Private can only be used inside the class.
2. Protected can be used inside the class and inherited classes. It cannot be used outside the class [that is, the instantiated object cannot be called]
3. Public applies to all scopes.
4. When a subclass overrides a method in a parent class, the scope of the access modifier in the subclass must be greater than or equal to the parent class's [ Inheritance can only be carried forward, or at least remain unchanged. Don't lose things. 】