Declaring methods
(modifier keyword) class name {
Member properties
Member Methods
}
Attention
1. A file only holds a class, the file name contains the class name, so the advantage of naming is convenient for later program automatic loading
2. The members of the class belong to this class
3. The member attributes should have the Modifier keyword, do not know what to add the words with Var
Instantiating an Object
$ object Name =new class name
Creating an object is allocating a space in memory
Out-of-object member access
Access by object
$ object Name->$ Property name =
$ object Name->$ method name ()
Access to members in an object
is to access other methods and member properties in the object's methods in an internal method of an object
Use the $this keyword to invoke the object of this method, which is equivalent to the first person "I"
$this cannot be accessed outside the class
The above describes the declaration and instantiation of the class, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.