class Staff
{
var $name;
var $city;
protected $wage;
function __get($propName)
{
echo "__get called!
";
$vars = array("name","city");
if (in_array($propName, $vars))
{
return $this->$propName;
} else {
return "No such variable!";
}
}
}
$employee = new Staff();
$employee->name = "Joe";
echo $employee->name."
";
echo $employee->age;
?>