Get your own PHP server Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<?php
// Interface definition
interface Animal {
  public function makeSound();
}
// Class definitions
class Cat implements Animal {
  public function makeSound() {
    echo " Meow ";
  }
}
class Dog implements Animal {
  public function makeSound() {
    echo " Bark ";
  }
}
class Mouse implements Animal {
  public function makeSound() {
    echo " Squeak ";
  }
}
// Create a list of animals
$cat = new Cat();
$dog = new Dog();
$mouse = new Mouse();
$animals = array($cat, $dog, $mouse);
// Tell the animals to make a sound
foreach($animals as $animal) {
  $animal->makeSound();
}
?>
 
</body>
</html>
Meow Bark Squeak