CodeIgniter Forums
Output generated html code before end of script execution - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Output generated html code before end of script execution (/thread-36225.html)



Output generated html code before end of script execution - El Forum - 11-25-2010

[eluser]jant90[/eluser]
Is it possible to output the so far generated html code with CodeIgniter? When I load a slow script now I don't see anything in my browser until the script is completely done.

For example take the default controller:
Code:
function index()
{
    $this->load->view('welcome_message');
    
    // Code to output all the html generated above
    
    sleep(10);
    echo("script is done loading");
}

How do I make sure my browser already gets to see the welcome message before the 10 second sleep kicks in?

Is it even possible?


Output generated html code before end of script execution - El Forum - 11-25-2010

[eluser]nuwanda[/eluser]
http://ellislab.com/codeigniter/user-guide/libraries/output.html

And read up on php's native buffering functions.


Output generated html code before end of script execution - El Forum - 11-26-2010

[eluser]jant90[/eluser]
Thanks. But I actually have read that but I still don't get how to send the entire buffer to the browser. I also tried all of the following but none of them worked:
ob_flush();
flush();
ob_end_flush();

Can anyone give me some clarification on this subject, as I really don't know where to start looking.


Output generated html code before end of script execution - El Forum - 11-26-2010

[eluser]nuwanda[/eluser]
It makes sense to post your code.