From: tassium Date: Thu, 3 Jul 2003 14:14:48 +0000 (+0000) Subject: New function: sm_print_r() X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=50cc40fe0544df6d560d5d1640d7141ed0b18ee0 New function: sm_print_r() This is intended to be a debugging function. Ever wanted to do a print_r, but found that some of the values were "eaten" by your browser's parser because they had <> in them? Use this function instead. It runs htmlentities() on the output of print_r() AND as a bonus wraps the entire thing in
 and 
tags. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5199 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/strings.php b/functions/strings.php index c9e583f6..ee4fa596 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -438,6 +438,23 @@ function makeComposeLink($url, $text = null) return makeInternalLink($url, $text, '_blank'); } +/** +* sm_print_r($some_variable); +* Debugging function - does the same as print_r, but makes sure special +* characters are converted to htmlentities first. This will allow +* values like to be displayed. +* The output is wrapped in
 and 
tags. +*/ +function sm_print_r($var) { + ob_start(); // Buffer output + print_r($var); + $buffer = ob_get_contents(); // Grab the print_r output + ob_end_clean(); // Silently discard the output & stop buffering + print "
";
+    print htmlentities($buffer);
+    print "
"; +} + $PHP_SELF = php_self(); ?>