Blogger Information
Blog 250
fans 3
comment 0
visits 321584
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
OOP 对象中的destruct 析构方法
梁凯达的博客
Original
937 people have browsed it

实例

<?php
	class Person{
		public $name;

		public function __construct($name){
			$this->name = $name;
			echo $name.'出生了。。。。<br/>';
		}

		//析构方法
		//在对象销毁的时候自动调用 作用 回收资源 写遗言
		public function __destruct(){
			echo $this->name.'凉凉了....<br/>';
		}

	}
	$p = new Person('西门大官人');
	//手动销毁对象
	unset($p);

	echo '昨天不知道你们看没看新闻 国足赢了!好厉害呀!<br/>';

运行实例 »

点击 "运行实例" 按钮查看在线实例

 

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post