Last active
December 14, 2015 06:19
-
-
Save rizz0/5041583 to your computer and use it in GitHub Desktop.
Simple class extension example.
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 Organ { | |
public function __construct($name){ | |
$this->name = $name; | |
} | |
public function kill(){ | |
echo $this->name.' died!<br/>'; | |
} | |
} | |
class Limb extends Organ { | |
public function snap(){ | |
echo $this->name.' snapped!<br/>'; | |
} | |
} | |
class Arm extends Limb { | |
public function punch(){ | |
echo $this->name.' threw a punch!<br/>'; | |
} | |
} | |
$organ = new Arm('Left Arm');; | |
$organ->punch(); | |
$organ->snap(); | |
$organ->kill(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment