Solved

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

Posted on 2008-10-16
4
479 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
  • 2
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
ddrudik earned 500 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

776 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