php析构函数不工作

php析构函数不工作,php,oop,destructor,Php,Oop,Destructor,我目前的php析构函数代码有问题 首先,我有一个基本的html文档,如下所示: <!doctype html> <html lang="en"> <head><title>Home</title></head> <body> <?php include('Table.php'); $T = new Table(); ?> </body> </html> 问题是,只有在

我目前的php析构函数代码有问题

首先,我有一个基本的html文档,如下所示:

<!doctype html>
<html lang="en">
  <head><title>Home</title></head>
<body>

<?php include('Table.php');
$T = new Table();
?>

</body>
</html>

问题是,只有在脚本终止后才调用析构函数,这是在/html标记输出之后。您缺少的只是一行代码,用于在脚本完全结束之前强制析构函数运行:
unset()

试试这个:

<?php include('Table.php');
$T = new Table();
unset($T);
?>

如需进一步阅读,请:

<?php include('Table.php');
$T = new Table();
unset($T);
?>