php object oriented magic methods in Chinese description

  • 2021-01-25 07:20:02
  • OfStack

1.__construct()

The instantiation object is called automatically. __construct is called when both __construct and a function with a class name exist, and the other one is not called.

Functions with class names are the older constructors.

2.__destruct()

Is called when an object is deleted or when an object operation ends.

3.__call()

Object calls a method. If the method does not exist, __call is called

4.__get()

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

5.__set()

Assignment to an object property is called if the property is private

6.__toString()

Is called when an object is printed.

7.__clone()

$a=new test(); $a1=clone $a;

8.__sleep()

Serialize was called before, if the object is large and you want to cut something in the serialization, you can use it.

9.__wakeup()

Unserialize is called to do some object initialization.

10.__isset()

Checking for the existence of an object property is called if the checked property is private.

11.__unset()

Deleting an object property is called if the deleted object property is private

12.__set_state()

Is called when var_export is called. __set_state as the return value of var_export.

13.__autoload()

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


Related articles: