Skip to content

Instantly share code, notes, and snippets.

@rizz0
Last active December 14, 2015 06:19
Show Gist options
  • Save rizz0/5041583 to your computer and use it in GitHub Desktop.
Save rizz0/5041583 to your computer and use it in GitHub Desktop.
Simple class extension example.
<?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