Use Poroperty Set

 
    <?php
   class Staff
   {
      var $name;
      function __set($propName, $propValue)
      {
         echo "Nonexistent variable: \$$propName!";
      }
   }   $employee = new Staff();
   $employee->name = "Joe";
   $employee->title = "Developer";?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.