A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearPHP: Best Method for Sequential Output? - page 1
User InfoPosts
PHP: Best Method for Sequential Output?#1
What is the best approach for setting up sequential output for a PHP installer script? Say I have a page, and want to display incremental output within a DIV provided by a PHP script.

So page.html might contain this:

<div id="output">
<!-- Script Output Here -->
</div>


And install.php might look like this (for testing purposes):

<?php
// Turn off Output Buffering
ob_end_flush();

// Begin Test Output (5 second intervals)
echo (Testing incremental output...( . "\n";
sleep(5);
echo (Step 1...( . "\n";
sleep(5);
echo (Step 2...( . "\n";
sleep(5);
echo (Complete!( . "\n";


I was thinking AJAX might be the best approach, but I(m not sure how to approach that. If I load "install.php" via JavaScript, I won(t get everything back until the script finishes execution (correct?) - making this entire goal moot. I(ve seen this done before, but can(t find a concrete example of how it was done.

Any help appreciated!

posted date: 2009-04-14 12:46:00


Re: PHP: Best Method for Sequential Output?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-14 12:46:01


Re: PHP: Best Method for Sequential Output?#3
I doubt Ajax will do what you want - instead you may have to call the ajax fetches more frequently. For flushing information out as soon as it(s produced you need regular flush()(s after outputting information.I(ve also added into a relevant .htaccess file a line to avoid any buffering due to GZipping the output as well (apache2).SetEnvIf Request_URI "/url/dont/buffer/me.php" gzip=0In the relevant PHP file:ini_set((output_buffering(, false);ini_set((implicit_flush(, (true();and the appropriate calls to flush(). That pretty much covers all the bases.

posted date: 2009-04-14 12:50:00


Re: PHP: Best Method for Sequential Output?#4
I would output everything to a text file and updating the DIV via AJAX by just calling the .txt file

posted date: 2009-04-14 21:52:00


Re: PHP: Best Method for Sequential Output?#5
Pretty hairy; multiple users? Then you've got multiple text files. Name the text file based on a session? What about multiple tabs? Oh crap I just divided by zero.

posted date: 2009-04-14 21:55:00


Re: PHP: Best Method for Sequential Output?#6
Ah, screw it. Just time your install script and create an animated GIF. It's all the same to the user.

posted date: 2009-04-14 22:16:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.