Qualcuno potrebbe salvare questi 2 file ed eseguirli e dirmi perché ottengo l'errore "ob_flush() [ref.outcontrol]: non è riuscito a svuotare il buffer. Nessun buffer da svuotare". Ho provato a googling e dice che devo usare ob_start(); ma quando lo faccio, non viene stampato riga per riga, ma restituisce l'intero oggetto dal ciclo FOR quando è stato completato. Sono un po 'nuovo a PHP in modo da non so dove altro guardare ..Errore PHP: ob_flush() [ref.outcontrol]: non è riuscito a svuotare il buffer. Nessun buffer da svuotare
test_process.php
// This script will write numbers from 1 to 100 into file
// And sends continuously info to user
$fp = fopen('/tmp/output.txt', 'w') or die('Failed to open');
set_time_limit(120);
ignore_user_abort(true);
for($i = 0; $i < 100; $i++){
echo "<script type=\"text/javascript\">parent.document.getElementById('foo').innerHTML += 'Line $i<br />';</script>";
echo str_repeat(' ', 2048);
flush();
ob_flush();
sleep(1);
fwrite($fp, "$i\n");
}
fclose($fp);
main.html
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css" media="screen">
.msg{ background:#aaa;padding:.2em; border-bottom:1px #000 solid}
.new{ background-color:#3B9957;}
.error{ background-color:#992E36;}
</style>
</head>
<body>
<iframe id="loadarea" width="1024px" height="768px"></iframe><br />
<script>
function helper() {
document.getElementById('loadarea').src = 'test_process.php';
}
function kill() {
document.getElementById('loadarea').src = '';
}
</script>
<input type="button" onclick="helper()" value="Start">
<input type="button" onclick="kill()" value="Stop">
<div id="foo"></div>
</body>
</html>
Controlla la tua configurazione in php.ini su buffer di uscita, può essere attivato per on_start automaticly. Un altro modo per verificare se è abilitato è usare ob_end_flush() all'inizio e rimuovere tutti i flussi. Inoltre puoi controllare con un 'phpinfo();' – dvicino
Hey, grazie per la tua risposta. Ho provato ad abilitare il buffering dell'output ma poi restituisce l'intero oggetto loop for anziché riga per riga ... – ThreaT