PHP析构函数

  • PHP 5引入了一个析构函数概念, 类似于其他面向对象的语言, 例如C ++。
  • 一旦删除了对特定对象的所有引用, 或者在关闭顺序中以任意顺序显式销毁了该对象, 则将调用析构函数方法。
  • 我们使用” __destruct”函数创建析构函数。

例子1

<?php
	class demo
	{
		public function demo()
		{
			echo "constructor1...";
		}
	}
	
	class demo1 extends demo
	{
		public function __construct()
		{
			echo parent::demo();
			echo "constructor2...";
		}
		public function __destruct()
		{
			echo "destroy.....";
		}
	}
	$obj= new demo1();
?>

输出

PHP析构函数

来源:

https://www.srcmini02.com/29306.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37974.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?