Result Size: 1264 x 19
x
 
<!DOCTYPE html>
<html>
<body>
<?php
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>
                
Я фрукт или ягода? Плод - клубника, красный цвет.