Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. <?php
  2.  
  3. class Person
  4. {
  5. public $name;
  6. protected $age;
  7. private $phone;
  8.  
  9. public function talk()
  10. {
  11. //Do stuff here
  12. }
  13.  
  14. protected function walk()
  15. {
  16. //Do stuff here
  17. }
  18.  
  19. private function swim()
  20. {
  21. //Do stuff here
  22. }
  23. }
  24.  
  25. class Tom extends Person
  26. {
  27. /*Since Tom class extends Person class this means
  28. that class Tom is a child class and class person is
  29. the parent class and child class will inherit all public
  30. and protected members(properties and methods) from
  31. the parent class*/
  32.  
  33. /*So class Tom will have these properties and methods*/
  34.  
  35. //public $name;
  36. //protected $age;
  37. //public function talk(){}
  38. //protected function walk(){}
  39.  
  40. //but it will not inherit the private members
  41. //this is all what Object inheritance means
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement