-
- function __destruct(){
- /* class initialization code */
- }
-
Copy code
The destructor is automatically called by the system and cannot take parameters.
Example:
-
- class des{
- function __destruct(){
- echo "Run ends, execute destructor";
- }
- }
- $p=new des(); /* Instantiate class */
- $sum=0;
- for($i=0;$i<10;$i++){
- $sum=$sum+$i;
- echo $sum ."
";
- }
- ? >
-
Copy code
|