[wp-hackers] debugging with print_r

Ozh ozh at planetozh.com
Fri Sep 14 19:00:54 GMT 2007


Hello there

Don't know if it's because I'm dumb or something like this, but I find
myself doing *a lot* of echo "<pre>";print_r($stuff);echo "</pre>";
when coding something to check how things are doing.

It's to a point that I've added the following to my wp-config.php :

function wp_print_r($input, $pre = true) {
	if ($pre) echo "<pre>\n";
	ob_start();
	print_r($input);
	$output = ob_get_contents();
	ob_end_clean();
	$output = attribute_escape($output);
	echo $output;
	if ($pre) echo "</pre>\n";
}

So, heh, you know, I thought, if some day committers run out of patch
to roll in, well, what an awesome addition it would make ;-Þ

Cheers,

Ozh
-- 
http://FrenchFragFactory.net ~ Daily Quake News
http://planetOzh.com ~ Blog & Code & WordPress Stuff


More information about the wp-hackers mailing list