Small example of php destructor

WBOY
Release: 2016-07-25 08:53:51
Original
1039 people have browsed it
  1. function __destruct(){
  2. /* class initialization code */
  3. }
Copy code

The destructor is automatically called by the system and cannot take parameters.

Example:

  1. class des{
  2. function __destruct(){
  3. echo "Run ends, execute destructor";
  4. }
  5. }
  6. $p=new des(); /* Instantiate class */
  7. $sum=0;
  8. for($i=0;$i<10;$i++){
  9. $sum=$sum+$i;
  10. echo $sum ."
    ";
  11. }
  12. ? >
Copy code


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template