1.__destruct

当对象销毁时候,自动调用方法

  1. <?php
  2. class show{
  3. function __construct(){
  4. }
  5. }
  6. ?>
<?php

class show{
    private $name;
    private $big;
    public function __construct($name){
    $this->name=$name;
    echo "{$name} 诞生了<br>";
    }
    public function __destruct(){
        echo "{$this->name} 销毁了<br>";
    }
}

$stu=new show('test');
?>

image.png