Home >Backend Development >PHP Tutorial >php学习类的使用

php学习类的使用

WBOY
WBOYOriginal
2016-06-23 13:44:471196browse

<?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!<br>";	}	function compute () {		return "编程!";	}	function __destruct(){		echo "<br>------------------------".$this->name;	}}$pc1=new MyPc("家用电脑");$pc2=new MyPc("公司电脑");$pc3=new MyPc("");echo $pc1->game();$pc1=null;echo "<br>".$pc2->name;?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn