Site icon DataFlair

PHP isset() Function with Examples

Program 1

<html>
<head><title>Demo</title></head>
<body>

    <center>
        <form method=post action=TestIsSet.php>
            Name:<input type=text name=txtname>
            <br>
            Department:<input type=text name=txtdept>
            <br>
            Salary:<input type=text name=txtsalary>
            <input type=submit value=Submit name=btnsubmit>

</form>
<?php 
  class Employee
  {
       public $empname;
       private $empdept;
       private $empsalary;
       public function setdata($dept,$sal)
       {
           $this->empdept=$dept;
           $this->empsalary=$sal;
       }
       public function __isset($pname)
       {
              echo isset($this->$pname);
       }
  }

  if(isset($_POST['btnsubmit']))
  {
      $e=new Employee();
     $e->empname="Vikas Sharma";
     $e->setdata('Computer',70000);
     echo isset($e->empname);
     echo isset($e->empdept);
    echo isset($e->empsalary);
  }
?>
</center>
</body>
</html>

 

Exit mobile version