[wp-hackers] debugging with print_r

Jacob Santos dragonwing at dragonu.net
Sat Sep 15 00:09:12 GMT 2007


This is the reason I'm building Unit Tests. If you do a search, you will 
find many papers and resources on doing this. PHPUnit and SimpleTest are 
two major ones for PHP. If you are just starting out SimpleTest would be 
a better solution. SimpleTest has documentation and tutorials. Sadly, 
there isn't much else to help you, if you are still interested. You can 
read what the author of PHPUnit has to say about Unit Tests, by 
searching for him and reading his phpWorks Presentation.

Jacob Santos

Ozh wrote:
> 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
>   


More information about the wp-hackers mailing list