当你声明一个类,你需要列出对象应有的所有变量和所有函数—被称为属性和方法。列表1中显示了一个类的构成. 注意在大括号({})内你只能声明变量或者函数。列表2中显示了如何在一个类中定义三个属性和两个方法。 列表1class Name extends Another Class { Access Variable Declaration Access Function Declaration } 列表2//定义一个跟踪用户的类 class User { //属性 public $name; private $password, $lastLogin; //方法 public function __construct($name, $password) { $this->name = $name; $this->password = $password; $this->lastLogin = time(); $this->access...