<?phpclass Person{???? private $name;???? private $sex;???? private $age;???? function __construct($name="",$sex="男",$age=1){?????????????????? $this->name=$name;?? ??? ??? $this->sex=$sex;?? ??? ??? $this->age=$age;???? }???? function __set($propertyName,$propertyValue){?? ????? if($propertyValue="sex"){?? ??? ????? if(!($propertyValue="女"||$propertyValue="男"))?? ??? ??? ????? return;?? ????? }?? ????? if($propertyName="age"){?? ??? ????? if($propertyName>150||$propertyName<0)?? ??? ??? ????? return;?? ????? }?? ?????????? $this->$propertyName=$propertyValue;????? /////////////這行代碼干嗎用! 的 是什么意思?。???? }????????? public function say(){?? ?? echo "我的名字:".$this->name."我的性別:".$this->sex."我的年紀(jì):".$this->age."<br>";?? ?? }}?? $person1 = new Person("張三","女",1);?? $person1->name="李四";?? $person1->say();?>
我想知道下 我下面的Php代碼 干嘛用的!
慕UI1458911
2017-04-20 19:10:32