复制代码代码如下:php
** 作用:为成员属性初始化;
*** 析构方法** 1.当对象被释放之前最后一个“自动”调用的方法* 使用垃圾回收器(java php),而c++手动 的释放** 作用:关闭一些资源,作一些清理的工作** __destruct();**/ class Person{var $name;var $age;var $sex;//php4中的构造方法/*function Person(){//每声明一个对象都会调用echo "1111111111111111";}*///php5中的构造方法function __construct($name,$age,$sex){$this->name=$name;$this->age=$age;$this->sex=$sex;}function say(){//$this->name;//对象中成员的访问使用$this echo "我的名字:{$this->name},我的年龄:{$this->age}"}function run(){}function eat(){}//析构方法function __destruct(){}}$p1=new Person("zhangsan",25,"男");$p2=new Person;$p3=new Person;
