Ngôn ngữ PHP - Tạo một destructor
Tạo một destructor
Mã nguồn PHP:
<!DOCTYPE html>
<html>
<body>
<?php
class Fruit {
public $name;
public $color;
function __construct($name) {
$this->name = $name;
}
function __destruct() {
echo "The fruit is {$this->name}.";
}
}
$apple = new Fruit("Apple");
?>
</body>
</html>