Home  >  Article  >  Backend Development  >  Solution to the invalid solution of using flush for PHP real-time output under IIS7

Solution to the invalid solution of using flush for PHP real-time output under IIS7

*文
*文Original
2017-12-29 18:06:111749browse

This article mainly introduces the method of php flush being invalid and php real-time output under IIS7. Friends in need can refer to it. I hope to be helpful.

In a relatively time-consuming operation, I want to record the operation and display it in real time on the browser. I 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);
}

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.

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

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.

Related recommendations:

php IIS log analysis search engine crawler recording program_php example

PHP IIS6.0 configuration pseudo-static is invalid, how to deal with it

##windows server 2008 php IIS cannot upload large files using uploadify Upload solution

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

Statement:
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