php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #47123 Robust Output Buffer Control
Submitted: 2009-01-16 03:26 UTC Modified: 2014-07-15 22:28 UTC
From: shepnorfleet at verizon dot net Assigned: mike (profile)
Status: Wont fix Package: *General Issues
PHP Version: 5.3.0alpha3 OS: linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: shepnorfleet at verizon dot net
New email:
PHP Version: OS:

 

 [2009-01-16 03:26 UTC] shepnorfleet at verizon dot net
Description:
------------
I would like to request the ability to place output at the front of the existing buffer.  I have placed an example CONOP in the 'Reproduce Code' section.  I did some experimentation with nesting but it doesn't seem to help me, please see the 'Expected Result' section to see if I understand it correctly.


Reproduce code:
---------------
<?
class Document {

...

function __destruct() 
{
      /*
       * By the time I get here the document has accumulated
       * javascript, and stylesheet includes.  My document
       * object ensures that these occur in the proper place
       * in the HTML document.
       */

      //New output goes to the front of the buffer.
      ob_insert(); 
      
      //write <html><head><title><style><script><body> tags
      $this->beginHTML(); 

      //Return to normal buffering mode
      ob_append(); 
      
      //write defered <script> and </body></html> tags
      $this->endHTML(); 

      ob_end_flush(); //All done
}
?>

Expected result:
----------------
<?

//Nesting doesn't seem to help
ob_start();
print "1";

ob_start();
print "2";
ob_end_flush();

print "3";
ob_end_flush();

?>

output is:
123

not: 
213

I need 213 not 123, see?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-15 22:28 UTC] yohgaki@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: mike
 [2014-07-15 22:28 UTC] yohgaki@php.net
This is how output buffer should work.
I understand use cases for this request. However, if you would like to insert/append data, you should insert/append during output, not into certain buffer. IMO. Please note that output buffer may flush automatically and the result is unpredictable. When whole data is buffered, appending data to parent buffer will be the same as inserting data. I don't think this feature is needed.

Mike might be interested in this feature. So I assigned this bug to him with wont fix status.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC