<?php header('Content-Type:text/html;charset=utf-8'); /* 封装 继承 多态 */ class Man { private $money = 1000; private $gender = '女'; public function showMoney() { return $this->money * 0.2; } } $a = new Man(); //echo $a->money."<br/>";//此时money是私有属性不能随便调用 // $a->name=500; // echo $a->name."<br/>"; echo $a->showMoney(); /* 此时a本来有1000元,但是外部人员却可以擅自修改 所以有时候我们有必要把函数封装起来,不让其他人擅自修改 */