Project management note sharing about object objects in PHP

Source: Internet
Author: User
1. When all instances are set to null,php, the object's references are automatically cleared.
2. Construction Sub: __construct ()
Methods to be executed automatically when objects are purged: __destruct ()
You can also set methods for manually purging objects: Destroy or CLEAN_UP
3. Three variable ranges in the object: public, private, and protected.
4. The constant attribute in the object can use the Const keyword and then be referenced outside the object in the format of the object name:: Property name, within the object in the format "Self:: Property name".
5. Properties that are common across all instances of an object are static properties that use the static keyword.
The difference between static and const is that the Public keyword can only be used before const, and static can use other keywords. Additionally, the static property is not read-only.
6. A common method in all instances of an entire object is a static method, which also uses the static keyword.
7. You can define an abstract class to define the interface. This class can only be inherited and cannot create instances. Inside the class, you define the methods that the subclass must provide by using abstract.
Any class that has an abstract method must use the abstract keyword before the class name.
Abstract class PRODUCR
8. By adding the final keyword before the method, you can prevent subclasses from override this method.
You can also add the final keyword before the class name, which means that other classes cannot inherit it.
9. The interface interface is used to define the structure of a series of abstract classes.
Interface IProduct
{
... ...
}
Abstract class Product implements IProduct
{
......
}
10.
= = Compares whether two objects are of the same type and whether they have the same value.
= = = Compares whether two objects are instances of the same class.
11. Clone of Class: Full copy 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 the print and ECHO functions.
13.get_class () Function: Returns the class name of an object.
14. You can add a class name to the Typehint of a function before the argument.
15. You can define a __autoload () function whose argument is that PHP cannot find a defined class name. You can define how to load automatically in this function.

The above describes project management's note-sharing about object objects in PHP, including the content of project management, and hopefully helps friends who are interested in PHP tutorials.

  • Related Article

    Contact Us

    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

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.