PHP Object-Oriented Magic method Chinese description

Source: Internet
Author: User
Tags call back

This article mainly introduced the PHP object-oriented Magic Method Chinese explanation, understands these methods only then writes the object-oriented program, needs the friend to be possible to refer to under

1.__construct ()

The instantiated object is called automatically. Call __construct when __construct and a function with the class name function name exist, and the other does not call back.

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

2.__destruct ()

When an object is deleted or an object operation ends is called.

3.__call ()

object to invoke a method. If the method does not exist, this call __call this method

4.__get ()

Reads an object property and calls it if the object property is private

5.__set ()

When you assign a value to an object property, it is invoked if the property is private

6.__tostring ()

Is invoked when an object is printed.

7.__clone ()

Called when the object is cloned, such as: $a =new test (); $a 1=clone $a;

8.__sleep ()

Serialize is called before, if the object is larger, want to cut a little something in serialization can use it.

9.__wakeup ()

Unserialize is invoked to do initialization work on some objects.

10.__isset ()

Detects whether an object's properties exist if the instrumented property is private and is invoked.

11.__unset ()

When you delete an object property, it is called if the object property being deleted is private

12.__set_state ()

Called when the Var_export is invoked. Use the return value of the __set_state as the return value of the Var_export.

13.__autoload ()

When an object is instantiated, the method is dropped if the corresponding class does not exist.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.