Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. <?php
  2.  
  3. class Person {
  4. private $name; // instance field
  5.  
  6. public function setName($name) { // instance method
  7. $this->name = $name;
  8. }
  9. public function getName() { // instance method
  10. return $this->name;
  11. }
  12. public static function getClassName() { // static method
  13. return "Person: ";
  14. }
  15. }
  16.  
  17. class Employee extends Person {
  18.  
  19. }
  20.  
  21. $e = new Employee();
  22. $e->setName("Eric");
  23. echo $e->getName();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement