0

I am trying to display the output from system('ping www.google.com -c 5'); in real time. The following code is working as intended, and displaying each ping as it completes in view source.The problem is when I am on the rendered page. The output is only displayed when all of the pings have completed. Is it possible to get the same functionality as view source in the rendered page?

<?php
ob_implicit_flush(true);
ob_end_flush();
system('ping www.google.com -c 5');
?>
Matthew
  • 1
  • 1
  • Disable output buffering entirely. That said, web pages should not depend upon un-buffered output for the display of "live" data as things like proxies, broken or timeout connections, and different browser behaviour all break the assumptions you're using. Instead you should perform the ping operation in an asynchronous background process on the server and use an AJAX or Comet side-channel for "live" information. I will concede that PHP does not have built-in support for threads, making this harder. – Dai Jun 13 '14 at 09:19
  • Duplicate of [Run process with realtime output in PHP](http://stackoverflow.com/questions/1281140/run-process-with-realtime-output-in-php) – kenorb Jun 13 '14 at 09:24
  • How would one go about calling a function asynchronously in PHP? – Matthew Jun 13 '14 at 09:27

0 Answers0