fork download
  1. <?php
  2.  
  3. class Fish {
  4. public $x, $y;
  5.  
  6. public function __construct($x, $y) {
  7. $this->x = $x;
  8. $this->y = $y;
  9. }
  10.  
  11. public function Draw() {
  12. echo "Fish has been drawn at $this->x:$this->y".PHP_EOL;
  13. }
  14. }
  15.  
  16. class Pike extends Fish {
  17. public function Draw() {
  18. parent::Draw();
  19. echo 'Im a pike, yo!'.PHP_EOL;
  20. }
  21.  
  22. public function PikeAction() {
  23. echo 'some action called from Pike class'.PHP_EOL;
  24. }
  25. }
  26.  
  27. $pike = new Pike(12, 12);
  28. $pike->Draw();
  29. $pike->PikeAction();
Success #stdin #stdout 0.01s 23532KB
stdin
Standard input is empty
stdout
Fish has been drawn at 12:12
Im a pike, yo!
some action called from Pike class