I have some classes I am writing unit tests for which have echoes in them. I want to suppress this output and thought ob_start() and ob_clean() would suffice, but they aren't having an effect.
public function testSomething (){
    ob_start();
    $class = new MyClass();
    $class->method();
    ob_clean();
}
I've also tried variations such as ob_start(false, 0, true); and ob_end_clean() to no avail.
What am I missing?
you may want something like this
<?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();
}
?>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With