Solved

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

Posted on 2008-10-16
4
470 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
Comment Utility
0
 
LVL 1

Author Comment

by:dban00b
Comment Utility
done and done!
0
 
LVL 27

Expert Comment

by:ddrudik
Comment Utility
Thanks for the question and the points.
0
 
LVL 1

Author Comment

by:dban00b
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now