我正在为一些类编写单元测试,这些类在其中有回声。我想抑制这个输出和想法ob_start()
and ob_clean()
就足够了,但它们没有效果。
public function testSomething (){
ob_start();
$class = new MyClass();
$class->method();
ob_clean();
}
我也尝试过诸如ob_start(false, 0, true);
and ob_end_clean()
无济于事。
我缺少什么?
你可能想要这样的东西
<?php
public function testSomething (){
ob_start();
ob_implicit_flush(false); // turn off implicit flush
// Make your output below
$class = new MyClass();
$class->method();
// End of output
// store output into variable:
$output = ob_get_contents();
}
?>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)