note 90891 modified in function.ob-start by danbrown
| From: | danbrown@php.net | Date: | Thu, 14 May 2009 21:17:45 +0000 |
| Subject: | note 90891 modified in function.ob-start by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154615@lists.php.net to get a copy of this message | ||
Hi,
Just wanted to share the problem I had with a fresh installation of Windows Server 2008 using IIS7
with PHP5.2.9-2 (windows MSI installer). Could also be applicable to earlier PHP builds on that
platform. It was installed as "IIS fastCGI". I've not really used windows server
until a recent project came up and came across a really annoying issue with output buffering. No
alteration of php.ini was required.
As you know, OB can be useful for user feedback e.g. timer or % complete effect.
The problem:
Everything installed perfectly (using binary mods as well). Scripts all ready in test rig i.e.
"default website" folder on IIS. They worked as normal except for output buffering -
nothing worked. The browser wouldn't flush anything until script execution had ceased. By
browser I refer to all common (IE, Firefox, Opera, Safari). Even installing latest build Apache,
bizarrely, (in case it was an IIS issue) yielded the same problem.
Example:
<?php
ob_start(); // Start output buffer (if not enabled in php.ini)
for($i=0; $i < 10; $i++)
{
echo $i, ' ';
ob_flush();
flush();
sleep(1);
}
?>
Expected: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 appearing incrementally every second in the browser.
Result: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 at once AFTER ten seconds.
I just couldn't get output buffering to work.
The Solution (requires admin rights):
Go to your server system drive e.g. c:\ and do the following...
C: > Windows > System32 > inetsrv > Config > applicationHost.Config
Go to the bottom of the page or look for your website e.g. <location path="Default Web
Site"> Default could be whatever your server is.
ORIGINAL LINE: <add name="php" path="*.php" verb="*"
modules="IsapiModule" scriptProcessor="C:\Program Files\PHP\php5isapi.dll"
resourceType="Unspecified" />
CHANGE TO: <add name="php" path="*.php" verb="*"
modules="IsapiModule" scriptProcessor="C:\Program Files\PHP\php5isapi.dll"
resourceType="Unspecified" responseBufferLimit="0" />
You MUST add responseBufferLimit="0"
By default, IIS buffers everything up to a massive 4MB (think it's to do with ASP) only
flushing after the script has finished execution. You need to override that and it's not really
documented, which is rather annoying.
Hooray... You will instantly find that output buffering should now functions as normal.
--was--
Hi,
Just wanted to share the problem I had with a fresh installation of Windows Server 2008 using IIS7
with PHP5.2.9-2 (windows MSI installer). Could also be applicable to earlier PHP builds on that
platform. It was installed as "IIS fastCGI". I've not really used windows server
until a recent project came up and came across a really annoying issue with output buffering. No
alteration of php.ini was required.
As you know, OB can be useful for user feedback e.g. timer or % complete effect.
The problem:
Everything installed perfectly (using binary mods as well). Scripts all ready in test rig i.e.
"default website" folder on IIS. They worked as normal except for output buffering -
nothing worked. The browser wouldn't flush anything until script execution had ceased. By
browser I refer to all common (IE, Firefox, Opera, Safari). Even installing latest build Apache,
bizarrely, (in case it was an IIS issue) yielded the same problem.
Example:
ob_start(); // Start output buffer (if not enabled in php.ini)
for($i=0; $i < 10; $i++)
{
echo $i, ' ';
ob_flush();
flush();
sleep(1);
}
Expected: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 appearing incrementally every second in the browser.
Result: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 at once AFTER ten seconds.
I just couldn't get output buffering to work.
The Solution (requires admin rights):
Go to your server system drive e.g. c:\ and do the following...
C: > Windows > System32 > inetsrv > Config > applicationHost.Config
Go to the bottom of the page or look for your website e.g. <location path="Default Web
Site"> Default could be whatever your server is.
ORIGINAL LINE: <add name="php" path="*.php" verb="*"
modules="IsapiModule" scriptProcessor="C:\Program Files\PHP\php5isapi.dll"
resourceType="Unspecified" />
CHANGE TO: <add name="php" path="*.php" verb="*"
modules="IsapiModule" scriptProcessor="C:\Program Files\PHP\php5isapi.dll"
resourceType="Unspecified" responseBufferLimit="0" />
You MUST add responseBufferLimit="0"
By default, IIS buffers everything up to a massive 4MB (think it's to do with ASP) only
flushing after the script has finished execution. You need to override that and it's not really
documented, which is rather annoying.
Hooray... You will instantly find that output buffering should now functions as normal.
http://php.net/manual/en/function.ob-start.php