我发现在 PHP 类中编写(file_put_contents
或简单fwrite
)是不可能__destruct()
的,如何调用它?全功能:
function __destruct()
{
foreach($this->data as $name=>$value) $$name=$value;
if(count($this->modules)>0)
{ foreach($this->modules as $name=>$value)
{
ob_start();
include $value;
$content=ob_get_contents();
ob_end_clean();
$$name = $content;
}
}
ob_start();
include $this->way;
$content = ob_get_contents();
ob_end_clean();
$fp = fopen('cache.txt', 'w+');
fputs($fp, $content);
fclose($fp);
echo $content;
}