set property : Properties set « Class « PHP






set property

<?php
   class Staff
   {
      var $name;
      function __set($propName, $propValue)
      {
         $this->$propName = $propValue;
      }
   }

   $employee = new Staff();
   $employee->name = "Joe";
   $employee->title = "Programmer";
   
   echo "Name: ".$employee->name;
   echo "<br />";
   echo "Title: ".$employee->title;
?>

           
       








Related examples in the same category

1.Use poroperty set