Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Looking for workaround: print_r and var_export cannot run with ob_start's callback function

Posted on 2008-10-16
4
Medium Priority
?
489 Views
Last Modified: 2008-10-16
the functions print_r() and var_export() cannot be run within my ob_start's callback function because those functions use ob_start() internally.  Does anyone know of a workaround so I can simply spit out an array within my callback?
<?php
function mycallback ($buffer){
	$array=(1,2,3,4,5);
	
	//neither of these work
	$result=print_r($array,true);
	$result=var_export($array,true);
 
	$buffer.="<div class=\"debug\">".$result."</div>";
 
	return $buffer;
}
 
  ob_start("mycallback");//buffer on
    include("helloworld.html");
  ob_end_flush();
 
?>

Open in new window

0
Comment
Question by:dban00b
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
ddrudik earned 2000 total points
ID: 22734404
0
 
LVL 1

Author Comment

by:dban00b
ID: 22734502
done and done!
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 22735594
Thanks for the question and the points.
0
 
LVL 1

Author Comment

by:dban00b
ID: 22735877
No problem, thank you!  I messed around with this for an hour or so before giving up and posting here, and you got my the solution in 10 minutes!!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question