1. When all instances are set to null,php, the object's references are automatically purged.
2. Construction Child: __construct ()
Methods to automatically execute when an object is cleared: __destruct ()
You can also set a method for manually purging objects: Destroy or CLEAN_UP
3. The range of three variables in the object: public, private, and protected.
4. Constant properties in objects can be referenced by using the Const keyword and then outside the object in the format of "Object Name:: Property name", within the object in the form of "Self:: property name."
5. Properties that are common in all instances of the entire object are static properties, using the static keyword.
The difference between static and Const is that only the public keyword is used before const, and static can use other keywords. In addition, the static property is not read-only.
6. The method that is common to all instances of the entire object is the static method, also using the static keyword.
7. You can define an abstract class to define the interface. This class can only be inherited, not created. Within the class, you define the method that subclasses must provide by using abstract.
A class that has an abstract method must use the abstract keyword before the class name.
Abstract class PRODUCR
8. Adding the final keyword before the method prevents subclasses from override this method.
The final keyword can be added before the class name, which means that other classes cannot inherit it.
9. Interface interface is used to define the structure of a series of abstract classes.
Interface IProduct
{
... ...
}
Abstract class Product implements IProduct
{
......
}
10.
= = Compare whether two objects are of the same type and whether they have the same value.
= = = Compare whether two objects are instances of the same class.
11. Class cloning: Full copy of the value.
$a = new SomeClass ();
$b = Clone $a;
You can define a __clone () function that specifically customizes the cloning behavior.
12. You can define the __tostring () method of a class to customize the behavior of using print and ECHO functions.
13.get_class () Function: Returns the class name of an object.
14. You can add a class name to the parameter of a function to indicate typehint.
15. You can define a __autoload () function whose argument is that PHP cannot find the defined class name. You can define how to load automatically in this function.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service