Advertisement
Guest User

Untitled

a guest
May 24th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.41 KB | None | 0 0
  1. <?php
  2.  
  3. class foo {
  4.     public function __construct() {
  5.         $this->monkey();
  6.     }
  7.  
  8.     protected function monkey() {
  9.         echo 'foo';
  10.     }
  11. }
  12.  
  13. class bar extends foo {
  14.     public function __construct() {
  15.         parent::__construct();
  16.     }
  17.  
  18.     protected function monkey() {
  19.         echo 'bar';
  20.     }
  21. }
  22.  
  23. echo 'Construct foo ' . "\n";
  24. $foo    = new foo();
  25. echo "\n\n";
  26.  
  27. echo 'Construct bar: ' . "\n";
  28. $bar    = new bar();
  29. echo "\n";
  30.  
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement