php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #36563 print_r, var_export, debug_print_backtrace use output buffering
Submitted: 2006-02-28 19:57 UTC Modified: 2006-03-07 02:13 UTC
From: jasper at album dot co dot nz Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
 [2006-02-28 19:57 UTC] jasper at album dot co dot nz
Description:
------------
It needs to be documented that print_r and var_export, with the second parameter TRUE, internally use output buffering to return their result rather than output it.

This causes them to fail when used within an output buffering callback handler.

Alternatively, this could be changed to a feature request and the code could be changed to not use output buffering.

Reproduce code:
---------------
<?php
function ob_handler( $in ) {
	return var_export( $in, true );
}

ob_start( 'ob_handler' );
echo "Hello";
?>

Expected result:
----------------
'Hello'

Actual result:
--------------
Fatal error: var_export(): Cannot use output buffering in output buffering display handlers in Command line code on line 2

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-07 02:13 UTC] vrana@php.net
"This function internally uses the output buffering with this parameter so it can not be used inside ob_start() callback function." by highlight_file(), highlight_string(), print_r() and var_export(). I see nothing wrong with debug_print_backtrace().
 [2006-03-07 02:13 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.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 09:01:32 2025 UTC