Link to home
Start Free TrialLog in
Avatar of dban00b
dban00b

asked on

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

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

ASKER CERTIFIED SOLUTION
Avatar of ddrudik
ddrudik
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dban00b
dban00b

ASKER

done and done!
Thanks for the question and the points.
Avatar of dban00b

ASKER

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!!