I use the PHP command line to create some files offline. To write the output of the script, I use the standard ob_start object:
ob_start(); // Echo lots of stuff $content = ob_get_contents(); // Now the $content can be written to a file
However, I also want to print some messages on the terminal (for example, warnings), collecting the "main output" in the buffer. Is there any way to do this? It does not seem to be possible to temporarily suspend buffering to print terminal messages, and then continue buffering from where it was left. Is there a workaround for this?
command-line php
Joonas pulakka
source share