Advertisement
Yousuf1791

Book-page-88

May 18th, 2022
630
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class User{
  4.     private $login_id = "";
  5.     private $active_status = "";
  6.  
  7.     public function __construct($id, $status){
  8.         $this->login_id = $id;
  9.         $this->active_status = $status;
  10.     }
  11.  
  12.     public function steLoginId($id){
  13.         $this->login_id = $id;
  14.     }
  15.  
  16.     public function setStatus($status){
  17.         $this->active_status = $status;
  18.     }
  19.  
  20.     public function getLoginId(){
  21.         return $this->login_id;
  22.     }
  23.  
  24.     public function getActiveStatus(){
  25.         return $this->active_status;
  26.     }
  27.  
  28.     public function showUserInfo(){
  29.         echo "Login Id : ". $this->login_id ."<br>";
  30.         echo "Active Status : ". $this->active_status ."<br>";
  31.     }
  32. }
  33.  
  34. class Employee{
  35.     private $user = null;
  36.     private $name = "";
  37.  
  38.     public function __construct($name, User $user){
  39.         $this->name = $name;
  40.         $this->user = $user;
  41.     }
  42.  
  43.     public function setName($name){
  44.         $this->name = $name;
  45.     }
  46.  
  47.     public function getUser(){
  48.         return $this->user;
  49.     }
  50.  
  51.     public function showEmployeeInfo(){
  52.         echo "<br>Employee Name : ". $this->name ."<br>";
  53.         echo "Login Status : <br>";
  54.         $this->user->showUserInfo();
  55.     }
  56. }
  57.  
  58. $user = new User("yousuf@tappware.com", "1");
  59. $e1 = new Employee("yousuf", $user);
  60.  
  61. // $e2 = $e1;
  62.  
  63. // $e2->setName("Emran");
  64. // $e2->getUser()->steLoginId("emran@dataware.com");
  65. // //
  66. // $e1->showEmployeeInfo();
  67. // $e2->showEmployeeInfo();
  68.  
  69. $e2 = clone $e1;
  70.  
  71. $e2->setName("Emran");
  72. $e2->getUser()->steLoginId("emran@dataware.com");
  73. //
  74. $e1->showEmployeeInfo();
  75. $e2->showEmployeeInfo();
  76.  
  77. ?>
Advertisement
RAW Paste Data Copied
Advertisement