Ver Mensaje Individual
  #9 (permalink)  
Antiguo 21/07/2010, 14:46
Avatar de neodani
neodani
 
Fecha de Ingreso: marzo-2007
Mensajes: 1.811
Antigüedad: 17 años, 2 meses
Puntos: 20
Respuesta: Progreso de un Bulce con %

Cita:
Iniciado por abimaelrc Ver Mensaje
Esta raro, a mí me funciona con output_buffering = on. Por eso es que se coloca el if al principio para verificar el output_buffering.
Pues a mi el código me funciona, cosa que ya había desistido porque en mi servidor local por más que tuviera esa variable en on o off no me iba.

Os acordáis de este post? se trataba lo mismo
http://www.forosdelweb.com/f18/mostr...-final-816188/

Sin embargo, nunca conseguí que funcionase este script en local

Código PHP:
Ver original
  1. <?php
  2. // All you need is 256 spaces first
  3. echo str_repeat(" ", 256)."<pre>"; flush();
  4.  
  5. // and ANY TAG before \r\n
  6. echo "working...<br/>\r\n"; flush(); sleep(5); // this in cycle
  7. echo "hola<br/>\r\n"; flush();sleep(5);
  8. echo "adios<br/>\r\n";
  9. ?>

Sin embargo, el que pone abimaelrc mas arriba sí!

Código PHP:
Ver original
  1. <?php
  2. $count = 300;
  3. if (ob_get_level() == 0) ob_start();
  4. for($i=0; $i<$count; $i++)
  5. {
  6.     echo round(($i / $count) * 100, 0) . '<br />';
  7.     print str_pad('',4096)."\n";
  8.    
  9.     ob_flush();
  10.     flush();
  11.     usleep(30000);
  12. }

No lo entiendo. Entonces no es cosa de mi servidor sino de cómo está hecho el script...

Intento hacer lo mismo poniendo en la primera linea
if (ob_get_level() == 0) ob_start();

Pero tampoco, no funciona, me muestra resultado cuando termina de ejecutarse! :S:S

Código PHP:
Ver original
  1. if (ob_get_level() == 0) ob_start();
  2. echo str_repeat(" ", 256)."<pre>"; ob_flush();flush();
  3.  
  4. // and ANY TAG before \r\n
  5. echo "working...<br/>\r\n"; ob_flush();flush(); usleep(5); // this in cycle
  6. echo "hola<br/>\r\n"; ob_flush();flush();usleep(50000000);
  7. echo "adios<br/>\r\n";

¿Es por el script, por qué uno funciona y el otro no?

Gracias de antemano!