1、创建一个类;<?php class Person{}?>.
2、加入几个属性:public $age; public $sex; public $name;
3、写构造方法:function __construct($age,$sex,$name){
$this->age=$age;
$this->name=$name;
$this->sex=$sex;
echo "My name is ".$this->name.",I am a ".$this->sex." I
am ".$this->age;
}
4、写析构方法: function __destruct(){
echo $this->name."销毁了<br />";
}
5、对类实例化:$p1=new Person(14,'boy','Jim');
$p2= new Person(10,'girl','Lucy');