php学习类的使用
程序员文章站
2022-03-30 15:11:56
...
name=$name; }*/ function __construct($name=''){ $this->name=$name; } function newfu(){ echo "this is ok!"; } function game () { return $this->name."play games!
"; } function compute () { return "编程!"; } function __destruct(){ echo "
------------------------".$this->name; }}$pc1=new MyPc("家用电脑");$pc2=new MyPc("公司电脑");$pc3=new MyPc("");echo $pc1->game();$pc1=null;echo "
".$pc2->name;?>