Exécuter
❯
Exécuter le code
Ctrl+Alt+R
Changer d'orientation
Ctrl+Alt+O
Changer de thème
Ctrl+Alt+D
<!DOCTYPE html> <html> <body> <?php class Fruit { public $name; public $couleur; public function __construct($name, $color) { $this->name = $name; $this->color = $color; } public function intro() { echo "Le fruit est {$this->name} et la couleur est {$this->color}."; } } class Strawberry extends Fruit { public $poids; public function __construct($name, $color, $weight) { $this->name = $name; $this->color = $color; $this->weight = $weight; } public function intro() { echo "Le fruit est {$this->name}, la couleur est {$this->color}, et le poids est {$this->weight} gram."; } } $strawberry = new Strawberry("Fraise", "rouge", 50); $strawberry->intro(); ?> </body> </html>
Le fruit est Fraise, la couleur est rouge, et le poids est 50 gram.