note 45002 deleted from function.print-r by didou

From: Date: Tue, 07 Sep 2004 20:19:53 +0000
Subject: note 45002 deleted from function.print-r by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76164@lists.php.net to get a copy of this message
Note Submitter: oracle dot shinoda at gmail dot com ---- I noticed that a lot of the examples below seem to make heavy use of recursion and other fancy features, without going for the easy solution. There's no need to use recursion, when print_r() already does 99% of the job! Here is my version of print_r(), with HTML entities escaped and the same format as the normal print_r(). <?php /** * printr * ------ * Function to produce the output of print_r() but in HTML * form. */ function printr ( $var, $do_not_echo = false ) { ob_start(); print_r($var); $code = htmlentities(ob_get_contents()); ob_clean(); if ( !$do_not_echo ) { echo "<pre>$code</pre>"; } return $code; } ?>

« previous php.notes (#76164) next »