<?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");
?>
もう一つの例:
例
<?php
class Fruit {
public $name;
public $color;
function construct($name, $color) {
$this->name = $name;
$this->color = $color;
}
function destruct() {
echo "The fruit is {$this->name} and the color is {$this->color}.";
}
}
$apple = new Fruit("Apple", "red");
?>