NEP -PHP PROGRAMMING

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10 PROGRAM 11 PROGRAM 12 PROGRAM 13 PROGRAM 14

PART B

. . .

5.

 
  
   
  5.Write a PHP script to implement constructor and destructor.
 < ? php
 
class Employee
{ 
     
    Public $name;
 
    Public $position;
 
    function __construct($name,$position)
 
    {
        // This is initializing the class properties
        $this->name=$name;
        $this->position=$position;
 
 
    }     
    function show_details()
    {
        echo $this->name." : ";
        echo "Your position is ".$this->position."<br>";
    }
     function __destruct()
            {
                echo "destroying " . $this->name . "<br>";
            }
}
     
$employee_obj= new Employee("Rakesh","developer");
$employee_obj->show_details();
     
$employee2= new Employee("Vikas","Manager");
$employee2->show_details();
 
? >