Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bdstefan/021b0bc48f8204f5cef2d1e6d24ec3a8 to your computer and use it in GitHub Desktop.
Save bdstefan/021b0bc48f8204f5cef2d1e6d24ec3a8 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