Any PHP developer who uses object-oriented building Web applications needs to master 6 keywords, respectively:
1.Private
2.Public
3.Protected
4.Static
5.Final
6.Abstract
For the first three keywords, they access relationships within the class as follows:
Private
As shown in the figure above, private is the core of access control, so a property (variable) or method that is defined as private in a class can only be accessed within that class, and no instance (object) or subclass of the class can be accessed, nor can you access it directly through the class name.
Protected
The protected access level is second only to private, and the attribute (variable) or method defined as protected can be accessed not only in this class, but also in subclasses of that class, which is not possible with the private property.
Public
Public has the greatest access rights, attributes (variables) or methods that are defined as public can be accessed at any point in the program, at any time.
Static
When we declare a property (variable) as static in a class, the value of the property is visible in all its objects and is a shared variable, so the static property value depends on the class rather than the object. Static properties cannot be accessed through objects, but rather by using the class name plus:: Symbol direct access.
Similarly, static methods have object-sharing attributes, but you need to note the following two points:
1. Directly through the class name plus:: Access static method
2. The $this keyword cannot be used in static methods
Final
If the property (variable) is final decorated, then the property (variable) value cannot be changed and, if it is a function, the function cannot be overwritten or overridden.
Abstract
Classes that are defined as abstract cannot be instantiated. Any class, if at least one of the methods inside it is declared abstract, then the class must be declared abstract. The method defined as abstract simply declares its invocation mode (parameters) and cannot define its specific function implementation.