<html>
<body>
class Fruit {
public $name;
public $color;
public function __construct($name, $color) {
$this->name = $name;
$this->color = $color;
}
public function intro() {
echo "Фрукт {$this->name} и цвет {$this->color}.";
}
}
// Strawberry унаследовано от Fruit
class Strawberry extends Fruit {
public function message() {
echo "Я фрукт или ягода? ";
}
}
$strawberry = new Strawberry("Strawberry", "red");
$strawberry->message();
$strawberry->intro();
</body>
</html>