<?php
class Person{ public $name; public $age; function __construct($name,$age) { $this->name=$name; $this->age=$age; } function __destruct(){ echo"{$this->name}消失"; } function say(){ echo "我叫{$this->name},我今年{$this->age}岁<br>"; return $this; } function eat(){ echo "{$this->name}正在吃饭<br>"; return $this; } function sleep(){ echo "{$this->name}正在睡觉<br>"; } public $sex="男"; function zuoshi(){ echo"{$this->name}的性别是{$this->sex}的<br>"; }}$Person_1=new Person("傅超","20");$Person_1->say()->zuoshi();$Person_2=new Person("吴慧颖","19");$Person_2->say()->eat()->sleep();?>