Forked from amacgregor/multiple_inheritance_diamond.php
Created
March 1, 2017 07:35
-
-
Save bdstefan/021b0bc48f8204f5cef2d1e6d24ec3a8 to your computer and use it in GitHub Desktop.
Diamond problem in PHP, showcasing the problem of multiple inheritance
This file contains 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