<?php
header('Content-type:text/html;charset=utf-8');
class Staff
{
private $name ;
// public $age ;
//öffentliches $Gehalt;
{ $this->name = $ Name; return $this->name ; } public function __set($name,$value) { if($name === 'age') { return false; } $this-> name=$value; }} $obj=new Staff('22',24,500); //echo $obj->name; echo $obj->age; echo '<hr>'; echo $obj->name; echo '<hr>'; echo $obj->salary;
类里面的私有成员没有数量限制