ob_flush pushes output before Joomla header

by Charles Wilkins IV   Last Updated September 30, 2019 19:10 PM - source

I have a module that I've created to test ob_flush buffering off. I need to understand it so I can have some longer modules buffer output to the page as the script goes through long processes. The code is working, however it is showing above the header of the page instead of in the module section (between the header and footer).

Here is the output buffering code:

<?php
// Turn off output buffering
ini_set('output_buffering', 'off');
// Turn off PHP output compression
ini_set('zlib.output_compression', false);

//Flush (send) the output buffer and turn off output buffering
while (@ob_end_flush());

// Implicitly flush the buffer(s)
ini_set('implicit_flush', true);
ob_implicit_flush(true);
ob_start();

for($x=0; $x<25;$x++) {
    echo "X=" . $x; 
    echo str_pad("",1024," ");
    echo "<br />";
    ob_flush();
    flush();

    sleep(1);        
} 


echo "Program Output";
ob_flush();
flush();
?>

Any insight on how to get this working properly would be appreciated. Here is a picture of the output:

enter image description here

Thanks, Chas



Related Questions


A PHP 7 question concerning =&

Updated June 08, 2017 15:10 PM

different templates based on $item number

Updated February 17, 2018 15:10 PM


Upgrade PHP to 7.2 cause error

Updated October 28, 2018 14:10 PM