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;
  }
  protected function intro() {
    echo "Плод {$this->name} и цвет {$this->color}.";
  }
}
class Strawberry extends Fruit {
  public function message() {
    echo "Я фрукт или ягода? ";
  }
}
// Попробуйте вызвать все три метода из внешнего класса
$strawberry = new Strawberry("Strawberry", "red");  // OK. __construct() is public
$strawberry->message(); // OK. message() is public
$strawberry->intro(); // ERROR. intro() is protected
?>
</body>
</html>
                
Я фрукт или ягода?