Advertisement
Ridwanwhy

Untitled

May 23rd, 2023
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <?php
  2. class User {
  3. public $firstName;
  4. public $lastName;
  5. public $userName;
  6.  
  7. protected $regID = 1001;
  8. private $level = 'User';
  9.  
  10. public function fullName(){
  11. return $this->firstName.' '.$this->lastName;
  12. }
  13.  
  14. protected function sayProtect(){
  15. return "Hello, Protected";
  16. }
  17.  
  18. private function sayPrivate(){
  19. return "Hello, Private";
  20. }
  21.  
  22. }
  23. class Customer extends User{
  24. public function sayParent(){
  25. return $this->sayProtect();
  26. }
  27. }
  28. $u = new User;
  29. $u->firstName = 'User';
  30. $u->lastName = 'Class';
  31. echo $u->regID."<br/>";
  32. echo $u->level."<br/>";
  33.  
  34. echo $u->fullName()."<br/>";
  35. echo $u->sayProtect()."<br/>";
  36. echo $u->sayPrivate()."<br/>";
  37.  
  38. $c = new Customer;
  39. $c->firstName = 'Customer';
  40. $c->lastName = "Dani";
  41. echo $c->fullName()."<br/>";
  42. echo $c->sayParent()."<br/>";
  43.  
  44.  
  45.  
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement