note 90891 added to function.ob-start

From: Date: Thu, 14 May 2009 21:16:40 +0000
Subject: note 90891 added to function.ob-start
Groups: php.notes 
Request: Send a blank email to php-notes+get-154614@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: 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. ---- Server IP: 92.48.74.199 Probable Submitter: 78.146.115.154 ---- Manual Page -- http://www.php.net/manual/en/function.ob-start.php Edit -- https://master.php.net/note/edit/90891 Del: integrated -- https://master.php.net/note/delete/90891/integrated Del: useless -- https://master.php.net/note/delete/90891/useless Del: bad code -- https://master.php.net/note/delete/90891/bad+code Del: spam -- https://master.php.net/note/delete/90891/spam Del: non-english -- https://master.php.net/note/delete/90891/non-english Del: in docs -- https://master.php.net/note/delete/90891/in+docs Del: other reasons-- https://master.php.net/note/delete/90891 Reject -- https://master.php.net/note/reject/90891 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#154614) next »