下面的__destruct()函数方法之间有什么区别?

时间:2019-12-19 11:32:36

标签: php oop

让我们采用一个简单的PHP类,其中定义了一些属性,即public / protected或private。 建议的方法与以下方法在功能和效果上的区别。

public function __destruct() {

    // unset all properties of this class
    foreach ( $this as $key => $value ) {
        unset ( $this->$key );
    }
}

public function __destruct() {
  // a blank __destruct method.
}

0 个答案:

没有答案