note 52863 modified in function.flush by danbrown

From: Date: Sat, 14 Feb 2009 06:07:43 +0000
Subject: note 52863 modified in function.flush by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-150659@lists.php.net to get a copy of this message
It is a bit complicated to work with the funktion flush() and you have to experiment with it a bit. So if you design a site which has a timeloop at the end that calls a other site via a form data input (Data Submit) you have to give something out to the buffer to get that new site loaden quick. For example: <?php $instant=gettimeofday(); $timenow=$instant["sec"];//Start Time //timeloop(e.g. for security_save after 30 min) while (1) { echo "<b></b>";//Useless (only to quickload next //or same Site when do a switch) flush(); //giveout buffer $instant=gettimeofday(); $timeactual=$instant["sec"]; //get Actual Time in Secs $flag=(($timeactual>$timenow+$diff)? 1:0);//$diff=switchTime if ($flag) { what_do_at_switch_Time();//Sec.Save etc.etc. $timenow=$timeactual; } //Set new Start Time sleep(5); //Or so...(Important) } //End of while-Loop ?> So you can programm a security save or other function in your site and if you do a switch the upload of the new or same site (the called site) works... --was-- It is a bit complicated to work with the funktion flush() and you have to experiment with it a bit. So if you design a site which has a timeloop at the end that calls a other site via a form data input (Data Submit) you have to give something out to the buffer to get that new site loaden quick. For example: $instant=gettimeofday(); $timenow=$instant["sec"];//Start Time //timeloop(e.g. for security_save after 30 min) while (1) { echo "<b></b>";//Useless (only to quickload next //or same Site when do a switch) flush(); //giveout buffer $instant=gettimeofday(); $timeactual=$instant["sec"]; //get Actual Time in Secs $flag=(($timeactual>$timenow+$diff)? 1:0);//$diff=switchTime if ($flag) { what_do_at_switch_Time();//Sec.Save etc.etc. $timenow=$timeactual; } //Set new Start Time sleep(5); //Or so...(Important) } //End of while-Loop So you can programm a security save or other function in your site and if you do a switch the upload of the new or same site (the called site) works... http://php.net/manual/en/function.flush.php

« previous php.notes (#150659) next »