Home > Backend Development > PHP Tutorial > Detailed explanation of php real-time output method under IIS7 when php flush is invalid

Detailed explanation of php real-time output method under IIS7 when php flush is invalid

黄舟
Release: 2023-03-07 07:24:01
Original
1200 people have browsed it

This article mainly introduces php flush is invalid, the method of real-time output of php under IIS7, friends who need it can refer to it

In a more time-consuming way During the operation, if you want to record the operation and display it in real time on the browser, you use flush() 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.

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.

The above is the detailed content of Detailed explanation of php real-time output method under IIS7 when php flush is invalid. 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