note 103523 modified in function.print-r by danbrown

From: Date: Mon, 18 Apr 2011 14:44:45 +0000
Subject: note 103523 modified in function.print-r by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-178941@lists.php.net to get a copy of this message
Since i use print_r for debugging a lot, i always use the following function in my scripts, which makes life a lot easier :-) <?php if (!function_exists("preprint")) { function preprint($s, $return=false) { $x = "<pre>"; $x .= print_r($s, 1); $x .= "</pre>"; if ($return) return $x; else print $x; } } ?> ------------------- USAGE: preprint($x); <- where $x = array(). ------------------- The optional 2. parameter can be set to "true", so the html-code is returned. Have fun, --was-- Since i use print_r for debugging a lot, i always use the following function in my scripts, which makes life a lot easier :-) if (!function_exists("preprint")) { function preprint($s, $return=false) { $x = "<pre>"; $x .= print_r($s, 1); $x .= "</pre>"; if ($return) return $x; else print $x; } } ------------------- USAGE: preprint($x); <- where $x = array(). ------------------- The optional 2. parameter can be set to "true", so the html-code is returned. Have fun, http://php.net/manual/en/function.print-r.php

« previous php.notes (#178941) next »