Skip to content

Latest commit

 

History

History
17 lines (13 loc) · 441 Bytes

destruct.md

File metadata and controls

17 lines (13 loc) · 441 Bytes

Destruct

PHP calls destructors as soon as objects are no longer available, and the destructor function takes no parameters

We should call parent::__destruct() after the local code for the destruction so that you are not destroying variables before using it

class MyClass
{
    public $name = 'MyClass';

    public function __destruct() {
        echo "{$this->name} is no more...\n";

        parent::__destruct();
    }
}