Advertisement
Guest User

Untitled

a guest
Feb 6th, 2012
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. <?php
  2. class foo {
  3.     public function printItem($string) {
  4.         echo 'Foo: ' . $string . PHP_EOL;
  5.     }
  6.    
  7.     public function printPHP() {
  8.         echo 'PHP is great.' . PHP_EOL;
  9.     }
  10. }
  11.  
  12. class bar extends foo {
  13.     public function printItem($string) {
  14.         echo 'Bar: ' . $string . PHP_EOL;
  15.     }
  16. }
  17.  
  18. $foo = new foo();
  19. $bar = new bar();
  20. $foo->printItem('baz'); // Output: 'Foo: baz'
  21. $foo->printPHP();       // Output: 'PHP is great'
  22. $bar->printItem('baz'); // Output: 'Bar: baz'
  23. $bar->printPHP();       // Output: 'PHP is great'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement