PHP magic method _ sleep _ wakeup (4) ,__ sleep _ wakeup. PHP magic method _ sleep _ wakeup (4), __sleep _ wakeup serialize can serialize variables including objects and convert them into continuous bytes data. you can save the serialized variable
In php, _ sleep and _ wakeup & nbsp; in php, __sleep and ___ wakeup are two methods called respectively before and after object serialization, _ sleep is called before an object is serialized. it does not receive any parameters but returns an array.
Php magic methods sleep () wakeup () _ sleep () and _ wakeup ()
Public array_ Sleep(Void)
Void_ Wakeup(Void)
The serialize () function checks whether a magic method _ sleep () exists in the class (). If this method exists, it is called first
_ Wakeup
1. _ call_ Call ($ method, $ arg_array) When an undefined method is called
A special method _ call () is added to the object in php tutorial 5, which is used to monitor other
Method. If you try to call a method that does not exist in an
1. The _ get and _ set methods are designed for attributes that are not declared in the class and their parent class: __get ($ property) this method is called when an undefined property is called; __ set ($ property, $ value) assigns & amp; 20540 to
Php magic methods are summarized from versions later than php5, and php classes can use magic methods. Php requires that all methods starting with two underscores (_) are retained as magic methods. Therefore, we recommend that you do not start with _
Php magic function and magic constant 1. _ Construct () is called when an object is instantiated. When _ construct and a function with the same class name exist at the same time, __construct is called, and the other is not called. 2. _ Destruct ()
This article describes how to use php magic methods (php magic functions). For more information, see
This article describes how to use php magic methods (php magic functions). For more information, see
The Code is as follows:
/** PHP treats
We all know that PHP Serialization can include objects and convert variables into continuous bytes data. you can save serialized variables in a file or transmit them over the network, then, the data is deserialized to the original data. This article
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.