[cc lang=”php”]
/*
https://stackoverflow.com/questions/1281140/run-process-with-realtime-output-in-php
*/
set_time_limit(0);
#ignore_user_abort();
function disable_ob() {
// Turn off output buffering
ini_set(‘output_buffering’, ‘off’);
// Turn off PHP output compression
ini_set(‘zlib.output_compression’, false);
// Implicitly flush the buffer(s)
ini_set(‘implicit_flush’, true);
ob_implicit_flush(true);
// Clear, and turn off output buffering
while (ob_get_level() > 0) {
// Get the curent level
$level = ob_get_level();
// End the buffering
ob_end_clean();
// If the current level has not changed, abort
if (ob_get_level() == $level) break;
}
// Disable apache output buffering/compression
if (function_exists(‘apache_setenv’)) {
apache_setenv(‘no-gzip’, ‘1’);
apache_setenv(‘dont-vary’, ‘1’);
}
}
header(“Content-type: text/plain”);
disable_ob();
echo shell_exec(‘ping 127.0.0.1’);
[/cc]