Home >Backend Development >PHP Tutorial >Detailed explanation of php real-time output method under IIS7 when php flush is invalid
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.'<br />'; @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.
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" />
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!