导读:
?php classhuman{ public$mood= 39; 39;; 心情,公有 private$money=500; 钱,私有的 publicfunctiongetmoney(){ return$this-...
PHP面向对象之private权限控制
-
class human{
-
-
public $mood='';
-
private $money=500;
-
-
public function getmoney(){
-
return $this->money;
- }
-
-
private function secret(){
-
-
echo '我那天偷吃了一块糖';
- }
-
-
public function tellme(){
-
-
$this->secret();
- }
-
- }
-
-
$lisi=new human();
-
$lisi->mood='happay';
-
-
echo $lisi->mood,'
';
-
-
echo $lisi->getmoney(),'
';
-
-
-
-
-
-
-
-
$lisi->tellme();
- ?>
-
class human{
-
-
public $mood='';
-
private $money=500;
-
-
public function getmoney(){
-
return $this->money;
- }
-
-
private function secret(){
-
-
echo '我那天偷吃了一块糖';
- }
-
-
public function tellme(){
-
-
$this->secret();
- }
-
- }
-
-
$lisi=new human();
-
$lisi->mood='happay';
-
-
echo $lisi->mood,'
';
-
-
echo $lisi->getmoney(),'
';
-
-
-
-
-
-
-
-
$lisi->tellme();
- ?>