Magic method
__destruct
gets called when we delete an object manually.
If we don't delete the object during the code execution, it will be called automatically at the end of the code execution
class User {
public $username;
public $friends = ['Tom','David'];
function __construct($name) {
$this->username = $name;
print $this->username . "'s object is created'\n";
}
function __destruct() {
print $this->username . "'s object is deleted'\n";
}
}
$user1 = new User('George');
$user2 = new User('David');
echo $user1->username . "\n";