我有一个脚本,它Obfuscate()
在显示内容之前对内容运行自定义电子邮件混淆类的功能,如下所示:
ob_start(array($obfuscator, "Obfuscate"));
include('header.php');
print($html);
include('footer.php');
ob_end_flush();
这一切都很好。但是,我已经完全重写了我的视图架构,所以我需要从类函数中运行电子邮件混淆并返回该字符串(然后被echo
编辑)。我最初将上面的内容重写为:
ob_start(array($this->obfuscator, "Obfuscate"));
include('header.php');
echo($this->content);
include('footer.php');
$wrappedContent = ob_get_contents();
ob_end_clean();
不幸的是,$this->obfuscator->Obfuscate()
回调没有被触发。从那以后,我了解到ob_get_contents()
不会触发回调,但也尝试过ob_get_clean()
并ob_get_flush()
无济于事。
那么,在触发回调后如何获取缓冲区的内容呢?