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 // Définition de l'interface interface Animal { public function makeSound(); } // Définitions de classe class Chat implements Animal { public function makeSound() { echo " Miaou "; } } class Dog implements Animal { public function makeSound() { echo " Aboyer "; } } class Souris implémente Animal { public function makeSound() { echo " Squeak "; } } // Créer une liste d'animaux $cat = new Cat(); $dog = new Dog(); $mouse = new Mouse(); $animals = array($cat, $dog, $mouse); // Dites aux animaux de faire un bruit foreach($animals as $animal) { $animal->faireDuBruit(); } ?> </body> </html>
Miaou Ouaf Couinement