Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class User{
- private $login_id = "";
- private $active_status = "";
- public function __construct($id, $status){
- $this->login_id = $id;
- $this->active_status = $status;
- }
- public function steLoginId($id){
- $this->login_id = $id;
- }
- public function setStatus($status){
- $this->active_status = $status;
- }
- public function getLoginId(){
- return $this->login_id;
- }
- public function getActiveStatus(){
- return $this->active_status;
- }
- public function showUserInfo(){
- echo "Login Id : ". $this->login_id ."<br>";
- echo "Active Status : ". $this->active_status ."<br>";
- }
- }
- class Employee{
- private $user = null;
- private $name = "";
- public function __construct($name, User $user){
- $this->name = $name;
- $this->user = $user;
- }
- public function __clone(){
- $this->user = clone $this->user;
- }
- public function setName($name){
- $this->name = $name;
- }
- public function getUser(){
- return $this->user;
- }
- public function showEmployeeInfo(){
- echo "<br>Employee Name : ". $this->name ."<br>";
- echo "Login Status : <br>";
- $this->user->showUserInfo();
- }
- }
- $user = new User("yousuf@tappware.com", "1");
- $e1 = new Employee("yousuf", $user);
- // $e2 = $e1;
- // $e2->setName("Emran");
- // $e2->getUser()->steLoginId("emran@dataware.com");
- // //
- // $e1->showEmployeeInfo();
- // $e2->showEmployeeInfo();
- $e2 = clone $e1;
- $e2->setName("Emran");
- $e2->getUser()->steLoginId("emran@dataware.com");
- //
- $e1->showEmployeeInfo();
- $e2->showEmployeeInfo();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement