Home > Backend Development > PHP Tutorial > PHP flush is invalid, PHP real-time output method under IIS7

PHP flush is invalid, PHP real-time output method under IIS7

墨辰丷
Release: 2023-03-29 08:06:01
Original
1500 people have browsed it

This article mainly introduces the invalid php flush and the real-time output method of php under IIS7. Friends who need it can refer to it

In a relatively time-consuming operation, I want to record the operation in real time on the browser When displayed, flush() is used to send the content in the buffer to the browser. But in iis7, PHP configured in fastcgi mode cannot be implemented, and the results are always displayed together.

for ($i=10; $i>0; $i--)
{
  echo $i.&#39;<br />&#39;;
  @ob_flush();
  flush();
  sleep(1);
}
Copy after login

The above code cannot gradually display the results under the default settings of IIS. The solution is as follows:

Open the file C:\Windows\System32\inetsrv\config\applicationHost.config. Note that if your system is 64-bit, this file must be opened with 64-bit editing software. 32-bit When opening the software, it will prompt that the file does not exist. Just use the notepad that comes with the system to open it. Find the following paragraph and add the red code, that is, add responseBufferLimit="0" to the php handler.

Copy code The code is as follows:

<handlers accessPolicy="Read, Script">
<add name="PHP_via_FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="E:\PHP\php-cgi.exe" resourceType="Either" responseBufferLimit="0" />
Copy after login

Now you can try it. If it still doesn’t work, set output_buffering = Off in php.ini.

The last point is very important. In different browsers, there are different results. There should be no problem in IE. If you use Chrome, each echo content must contain html, otherwise it will not work. Also, if the echo content is too short, this effect cannot be achieved. You can output it before the code. A space, such as: echo str_pad(' ', 1050); Chrome seems to have to output more than 1000 characters first to have this effect. If it doesn't work, try more.

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

Related recommendations:

use keyword and file loading in PHP

phpWeChat public account Detailed explanation of development mode

php WeChat public platform interaction and interface detailed explanation

The above is the detailed content of PHP flush is invalid, PHP real-time output method under IIS7. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template