Last active
March 1, 2017 07:35
-
-
Save amacgregor/9456741 to your computer and use it in GitHub Desktop.
Diamond problem in PHP, showcasing the problem of multiple inheritance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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