délai côté php
This commit is contained in:
21
question.php
21
question.php
@@ -1 +1,20 @@
|
||||
<?php echo `python markov.py`; ?>
|
||||
<?php
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
header('Cache-Control: no-cache'); // pour éviter le buffering du navigateur
|
||||
header('X-Accel-Buffering: no'); // si nginx, pour désactiver le buffering
|
||||
|
||||
$reponse = `python markov.py`;
|
||||
|
||||
// désactiver le buffering PHP
|
||||
@ini_set('output_buffering', 'off');
|
||||
@ini_set('zlib.output_compression', 'off');
|
||||
while (ob_get_level()) ob_end_flush();
|
||||
flush();
|
||||
|
||||
// envoyer chaque lettre avec un délai
|
||||
$len = strlen($reponse);
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
echo $reponse[$i];
|
||||
flush(); // forcer l'envoi immédiat
|
||||
usleep(40000); // 40ms = 40000 microsecondes
|
||||
}
|
||||
Reference in New Issue
Block a user