PHP析构函数示例

<?php
class MyClass 
{

	function __construct()
	{

	print "在构造函数中";

	$this->name = "MyClass对象";

	}

	function __destruct()
	{

	print "销毁 " . $this->name . "\n";

	}

}

 

$obj = new Myclass();

?>

PHP析构函数

析构函数是"OOP面向对象编程"的另一个功能。
析构概念在PHP5中引入,并且在概念上类似于其他面向对象语言的概念性。
一旦没有其他对特定对象或者对象明确地销毁了该对象时,就会调用析构函数方法。

PHP中的析构函数是什么

如何在PHP中使用析构函数?

日期:2020-04-18 01:09:15 来源:oir作者:oir