Php object-oriented magic methods description in Chinese _ PHP Tutorial

Source: Internet
Author: User
Php object-oriented magic methods are described in Chinese. 1. the _ construct () instantiated object is automatically called. When _ construct and a function with the class name exist at the same time, _ construct is called, and the other one does not call it back. Function name function 1. _ construct ()

The instantiated object is automatically called. When _ construct and a function with the class name exist at the same time, _ construct is called, and the other one does not call it back.

The class name function is the old version of the constructor.

2. _ destruct ()

When an object or object is deleted, it is called.

3. _ call ()

Object to call a method. If the method does not exist, call the _ call method.

4. _ get ()

Read an object property. if the object property is private, it will be called.

5. _ set ()

When an object property is assigned a value, if the property is private, it will be called.

6. _ toString ()

When printing an object, it is called.

7. _ clone ()

Called when an object is cloned, for example, $ a = new test (); $ a1 = clone $;

8. _ sleep ()

Serialize is called before. if the object is large, you can use it to delete something before serialization.

9. _ wakeup ()

Unserialize is called to initialize objects.

10. _ isset ()

Checks whether an object's attribute exists. if the detected attribute is private, it is called.

11. _ unset ()

When deleting an object property, if the deleted object property is private, it will be called.

12. _ set_state ()

Called when var_export is called. Use the return value of _ set_state as the return value of var_export.

13. _ autoload ()

When instantiating an object, if the corresponding class does not exist, the method will be deprecated.

The http://www.bkjia.com/PHPjc/736805.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/736805.htmlTechArticle1.__construct () instantiated object is called automatically. When _ construct and a function with the class name exist at the same time, _ construct is called, and the other one does not call it back. Function name...

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.