class User extends AnotherClass { //Access Variable Declaration public $name; public $password; public $lastLogin; //Access Function Declaration public function __construct($name,$password){ $this->name = $name; $this->password = $password; $this->lastLogin = time(); } // 获取最后访问的时间 public function getLastLogin(){ return(date("M d Y", $this->lastLogin)); } } //创建一个对象的实例 $user = new User("Leon", "123456"); //获取最后访问的时间 print($user->getLastLogin() ."n"); //打印用户名 print("$user->name");