Skip to content

Instantly share code, notes, and snippets.

@humbertocastelo
Created March 28, 2017 19:55
Show Gist options
  • Save humbertocastelo/b5b4256c5b70efe57a3bdd218e65eceb to your computer and use it in GitHub Desktop.
Save humbertocastelo/b5b4256c5b70efe57a3bdd218e65eceb to your computer and use it in GitHub Desktop.
Print Flush
<?php
error_reporting( E_ALL );
ini_set( 'display_errors', true );
if ( !headers_sent() ) {
header( 'X-Accel-Buffering: no' );
}
function is_apache2() {
static $bool;
if ( isset( $bool ) ) {
return $bool;
}
$bool = ( php_sapi_name() !== 'cli' );
return $bool;
}
function print_flush( $input ) {
if ( is_apache2() ) {
print $input;
ob_flush();
flush();
} else {
print strip_tags( str_replace( array( '<br/>', '<br>' ), "\x0a", $input ) );
}
}
print_flush( 'Oi' . '<br/>' ); sleep(5);
print_flush( 'Eu sou o Goku' . '<br/>' ); sleep(5);
print_flush( "\x0a" );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment