Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to have PHP print the data to a web browser in real time?

Tags:

php

For example, if I have an echo statement, there's no guarantee that the browser might display it right away, might display a few dozen echo statements at once, and might wait until the entire page is done before displaying anything.

Is there a way to have each echo appear in a browser as it is executed?

like image 598
Thomas Owens Avatar asked Sep 25 '08 15:09

Thomas Owens


People also ask

How can we display the output directly to the browser in PHP?

Answer. In order, to display the output directly to the browser, we have to use the special tags <?

How can you get Web browser's details using PHP?

The get_browser() function in PHP is an inbuilt function that is used to tell the user about the browser's capabilities. This function looks up the user's browscap. ini file and returns the capabilities of the user's browser.

How do I display PHP output?

With PHP, there are two basic ways to get output: echo and print . In this tutorial we use echo or print in almost every example. So, this chapter contains a little more info about those two output statements.

Can a browser read PHP?

No, they can't. PHP is a server-side scripting language, the browser never actually sees the php code.


1 Answers

You can use flush() to force sending the buffer contents to the browser.

You can enable implicit flushing with "ob_implicit_flush(true)".

like image 114
blueyed Avatar answered Oct 16 '22 16:10

blueyed