Correcting teacher:查无此人
Correction status:qualified
Teacher's comments:完成的不错,继续加油。写作业,最好能加上自己的看法或总结。
<?php class work{ public $name = '肃宁工区'; public $address = '河北沧州'; public $telephone = '5088888'; public function getInfo1(){ $obj = new self(); return '工区:' .$obj->name . ',地址:' . $obj->address . ',电话:' .$obj->telephone . '<br>'; } public function getInfo2(){ return '工区:' . $this->name .',地址:' .$this->address .'<br>'; } } $sn = new work(); echo $sn->name; echo '<hr>'; echo $sn->getInfo1(); echo '<hr>'; echo $sn->getInfo2(); echo '<hr>'; $methods = get_class_methods('work'); echo '<pre>'.print_r($methods,ture); echo '<hr>';
<?php class work { public $name; public $address; public $telephone; public function __construct($name,$address,$telephone) { echo '开始执行'; echo '<hr>'; $this->name = $name; $this->address = $address; $this->telephone = $telephone; } public function getInfo() { return '工区:' . $this->name . ',地址:' . $this->address . ',电话:' . $this->telephone .'<br>'; } } $sn = new work('肃宁工区','河北沧州','13888888'); echo $sn->getInfo();