PHP Program to Create Class Employee to Accept and Display Data

Question: Write a PHP program to create a class employee with data members eno, name, salary, designation and memeber functions to accept data and display data. Accept data for 5 employees and display the information.

HTML Code to Accept Employee Information

<!-- Employee.html -->
<head><title>Fill Employee Details</title
<h2>Enter Information for 5 Employees (Use space for separation)</h2>
<form action="employee.php" method"POST">
Enter Employee Nos: 
<input type="text" name = "nos" /><br>
Enter Employee names: 
<input type="text" name = "names" /><br>
Enter respective salaries:
<input type="text" name = "sal" /><br>
Enter designations:
<input type="text" name = "des" /><br><br>
<input type="submit" /><input type="reset" /><br>

PHP Code to Display the Accepted Employee Information


$enos = explode(" ",$_POST['enos'], 5);
$names = explode(" ",$_POST['names'], 5);
$salaries = explode(" ",$_POST['sal'], 5);
$des = explode(" ",$_POST['des'], 5);

class Employee
   var $eno;
   var $name;
   var $sal;
   var $des;

   public function acceptData($eno, $name, $sal, $des)
     $this->eno = $eno;
     $this->name = $name;
     $this->sal = $sal;
     $this->des = $des;

   public function display data()
     echo "Employee no is $eno <br>";
     echo "Employee name is $name <br>";
     echo "Employee salary is $sal <br>";
     echo "Employee designation is $des <br>";

$emp_info_array[] = new Employee();

for($i = 0; $i < 5; $i++)
   $emp_info_array[$i] = new Employee();
   $emp_info_arrays[$i]->acceptData($enos[$i], $names[$i], $salaries[$i],$des[$i]);