illustrate
1. It is automatically triggered when the class is destroyed. You can use the unset method to trigger this method.
2. An optional part of the class, usually used to complete some cleaning tasks before the object is destroyed. The destructor cannot take any parameters.
Format:
function __destruct ( ) { ... ... }
Example
<?php class autofelix { public function __destruct() { echo 'I'm ready to destroy you'; } } $a = new autofelix(); unset($a); //Output: I am ready to destroy you
The above is an introduction to the __destruct method in PHP. I hope it will be helpful to everyone.