php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #31929 Output Buffering Bug
Submitted: 2005-02-11 07:56 UTC Modified: 2005-04-17 17:54 UTC
From: clover at fromru dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.* OS: WinXP, SuSe 9.2 (PHP:4.3...)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: clover at fromru dot com
New email:
PHP Version: OS:

 

 [2005-02-11 07:56 UTC] clover at fromru dot com
Description:
------------
i'm using ob_start() with a callback function; internally in it i use $res=var_export($var, TRUE) function but got an error:
[11-Feb-2005 08:28:15] PHP Fatal error:  var_export() [<a href='ref.outcontrol'>ref.outcontrol</a>]: Cannot use output buffering in output buffering display handlers in E:\htdocs\index.php on line XXX

Reproduce code:
---------------
<?php
ob_start("my_shutdown_function");

function my_shutdown_function($buffer){
  $var=headers_list();
  $res=var_export($var, TRUE);
  return($res);
}

print("something...");
?>

Expected result:
----------------
the "dump" of all sent headers instead of string "something..."

Actual result:
--------------
"PHP Fatal error..."

Comment: this error actually must be when i call var_dump() or var_export($var, FALSE) in output buffering handler.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-05 15:00 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

You can't even call functions using the output buffering functions like print_r($expression, true) or highlight_file($filename, true) from a callback function.
 [2005-04-13 11:36 UTC] derick@php.net
This is not a documentation bug, please revert your patch Jakub - this also works fine in PHP 4.3 and should work fine in PHP 5.x.
 [2005-04-16 16:32 UTC] sniper@php.net
Try this instead:

<?php
ob_start('foo');function foo ($buffer) { return var_export($buffer,true); } echo "bar!"; 
?>

It does exactly same thing in PHP 4.3.x and PHP 5.x.x
so Jakub is right here..


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 08 14:01:33 2025 UTC