Any PHP developer must master six keywords when using object-oriented WEB applications:
1. Private
2. Public
3. Protected
4. Static
5. Final
6. Abstract
For the first three keywords, their internal access relationships within the class are as follows:
Private
As shown in, Private is the core part of access control. Therefore, attributes (variables) or methods defined as Private in a class can only be accessed within this class, no instance (object) or subclass of this class can be accessed. Similarly, you cannot directly access this class by class name.
Protected
The access level of Protected is second only to Private. attributes (variables) or methods defined as Protected can be accessed not only in this class, but also in subclass of this class, this is not applicable to Private attributes.
Public
Public has the maximum access permission. attributes (variables) or methods defined as Public can be accessed at any position or time of the program.
Static
When we declare an attribute (variable) as static in the class, the value of this attribute is visible in all its objects and is a shared variable. Therefore, the static property value depends on the class rather than the object. Static attributes cannot be accessed through objects, but are directly accessed using class names plus.
Static methods also share objects, but note the following:
1. Access the static method directly by using the class name plus:
2. The $ this keyword cannot be used in static methods.
Final
If the attribute (variable) is modified by Final, the value of this attribute (variable) cannot be changed. If it is a function, the function cannot be overwritten or overwritten.
Abstract
Classes defined as Abstract cannot be instantiated. If at least one method in a class is declared as Abstract, the class must be declared as Abstract. A method defined as Abstract only declares its call method (parameters) and cannot define its specific function implementation.