Tag: Operation ISS Resource cannot start with recommended void error INF
__construct (), __destruct (), __call (), __callstatic (), __get (), __set (), __isset (), __unset (), __sleep (), __wakeup (), __ ToString (), __invoke (), __set_state (), __clone (), and __debuginfo () are known in PHP as "Magic Methods" (Magic methods). You cannot use these method names when naming your own class methods, unless you want to use their magic features.
If there is a system check out the Magic method will call itself.
Caution
PHP retains all class methods that begin with __ (two underscores) as a magic method. Therefore, in addition to the above magic method when defining a class method, it is recommended that you do not prefix __.
__sleep () and __wakeup ()
Public array __sleep (void)
void __wakeup (void)
The serialize () function checks to see if there is a magic method __sleep () in the class. If present, the method is called first before the serialization operation is performed. This feature can be used to clean up objects and return a
An array that contains all the variable names that should be serialized in the object. If the method does not return anything, NULL is serialized and a E_notice level error is generated.
Note:
__sleep () cannot return the name of the private member of the parent class. Doing so produces a e_notice level of error. Can be replaced with Serializable interface.
The __sleep () method is commonly used to commit uncommitted data, or similar cleanup operations. At the same time, if there are some very large objects, but do not need to save all, this function is very useful.
In contrast, unserialize () checks for the existence of a __wakeup () method. If present, the __wakeup method is called before the resource required by the object is prepared beforehand.
__wakeup () is often used in deserialization operations, such as re-establishing a database connection, or performing other initialization operations.
The Magic method in PHP