An output buffer is a mechanism to capture all input of output function
Note that once the buffer is above its max limit set by output-buffering (get its actual size with ob_get_length), there is automatic flush.
ob_start();
echo "My output"
print "Whatever"
ob_get_contents();
ob_end_clean();
This is a nested feature meaning that a sub-function may also create and end a capture session (ob_start, ob_end) to capture the output of its own instructions
ie:
See the dedicated page: How to solve Test code or tested code did not (only) close its own output buffers