First, abstract a class
1. Concept:
Object: Entity of an objective transaction
Class: An abstract description of an entity
Class cannot be used directly, only after instantiation (new) can be used
2, naming: The name of the class is equivalent to the name of the function, note: The class name is case-insensitive (variable names are case-sensitive)
Class: Capitalize the first letter of all words such as goodpeople
Method (function): Initial letter of the first word is capitalized after the first letter of the word, such as Loadsay
3. Composition
A class can define member methods (functions) or you can define member properties (variables)
4. Declaration of Class
"Some modified keywords" class name {
Members of the class;
}
5. Attributes of a member (a variable declared directly in a class)
Example 1-1:class person{
var $name;
var $sex;
var $age;
}
Note: When declaring a member property in a class, it is important to use a keyword before the variable, and if you do not need to have a specific adornment, use the "var" keyword, and if there are other keywords in the member properties, you need to remove "var" keyword, you can only have member properties and member methods inside a Class!!! There can be no other, there cannot be two classes of the same name in a script , the instantiation class may have multiple objects
Example 1-2:class person{
Public $name; Shared Permissions
Private $sex; Private Permissions
Static $age; Static Permissions
}
3.methods of the members (functions declared directly in the class)
Example 1-3:class person{
function say () {
method Body
}
}
PHP Object-oriented-abstract a class