Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. <?php
  2.  
  3. abstract class Person {
  4.  
  5.   abstract public function getName();
  6.  
  7.   public function getIntroduction() {
  8.     return sprintf(
  9.       'My name is %s',
  10.       $this->getName()
  11.     );
  12.   }
  13. }
  14.  
  15. class Joaquin extends Person {
  16.  
  17.   public function getName() {
  18.     return 'Joaquin';
  19.   }
  20. }
  21.  
  22. $joaquin = new Joaquin();
  23. print $joaquin->getIntroduction();
  24. // This prints "My name is Joaquin"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement