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."
";
}
function __destruct()
{
echo "destroying " . $this->name . "
";
}
}
$employee_obj= new Employee("Rakesh","developer");
$employee_obj->show_details();
$employee2= new Employee("Vikas","Manager");
$employee2->show_details();
? >