-1

I coded that script in php:

foreach($hey[1] as $key => $val){
    $data2 = get_page_code($val);
    preg_match($patternredirect, $data2 ,$url);
    echo $url[1];
}

The code is not actually relevant, the issue is when I run it the page doesn't show anything until the page is fully loaded. In my previous host the echo used to be shown while the code was being executed. Is it a way to change it and show things once got them and not to wait until every $url[1] is got? Thanks :)

1 Answers1

0

Even if you flush the output, your browser may still simply refuse to display anything until the whole page is sent. A workaround is to create a JavaScript page that connects to the PHP server via a web socket, create a web socket server in PHP, then send the data in packets to the client and reconstruct it on the other end.

wizzwizz4
  • 6,140
  • 2
  • 26
  • 62
  • Then how's possible in my previous host with the exact code the content was shown once got it? – Ismael Quirantes Jul 06 '18 at 21:22
  • *may. The real answer is that I don't know (probably a default buffer size difference)... But some browsers will emulate this _anyway_, so you can't rely on the output buffering causing the user to be able to see the things live. Try the Python documentation's search tool to test this between browsers. – wizzwizz4 Jul 06 '18 at 21:28