热搜:NVER node 开发 php

php学习类的使用

2024-08-17 11:25:01
php学习类的使用

<?phpclass MyPc {	var $hpf;	public $name;	/*function MyPc ($name='') {		$this->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;?>