Skip to content

Instantly share code, notes, and snippets.

@amacgregor
Last active March 1, 2017 07:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save amacgregor/9456741 to your computer and use it in GitHub Desktop.
Save amacgregor/9456741 to your computer and use it in GitHub Desktop.
Diamond problem in PHP, showcasing the problem of multiple inheritance
<?php
class Cat {
public function roar() { /** Do Something **/ }
}
class Tiger extends Cat {
public function roar() { /** Do Something Different **/ }
}
class Lion extends Cat {
public function roar() { /** Do Something More Different **/ }
}
class Liger extends Lion, Tiger {}
// Create a new Liger
$liger = new Liger;
// Try to call the roar class
$liger->roar();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment