return $much; } } public function showMoney(){ return $this->money; } public function showBank(){ return $this->bank; } } $lisi = new Human(); $flag = $lisi->send(2000); if($flag){ echo '借了',$flag,'元<br />'; echo '还剩',$lisi->showMoney(),'元<br />'; echo '银行还有',$lisi->showBank(),'元<br />'; } ?>
<?php /* 封装,在方法上的体现 */ header('Content-Type:text/html;charset=utf-8'); class Human{ private $money = 1000; public function showMoney(){ return $this->money; } } $p1 = new Human(); echo $p1->showMoney(); ?>