note 113399 added to function.print-r

From: Date: Sun, 06 Oct 2013 11:40:25 +0000
Subject: note 113399 added to function.print-r
Groups: php.notes 
Request: Send a blank email to php-notes+get-196479@lists.php.net to get a copy of this message
function : debug_print <?php // -------------------------------------------------------------- function debug_print($var, $nfo='DEBUG', $htm=false, $ret=false) { $var_str = print_r($var, true); if ($htm !== false) { $var_str = htmlentities($var_str); } $outstr = ''; $outstr = '<p>--------- <strong>'.$nfo.'</strong> ---------</p>'."\n"; $outstr .= '<pre style="margin:18px 4px; padding:6px; text-align:left; background:#DEDEDE; color:#000099;">'."\n"; $outstr .= $var_str."\n"; $outstr .= '</pre>'."\n"; if ($ret !== false) { $result = $outstr; } else { print $outstr; $result = true; } return $result; } // -------------------------------------------------------------- ?> usage: <?php // -------------------------------------------- $data = array('some', 'example', 'test'); // --- direct output --- debug_print($data); // --- returned output --- $debug_str = debug_print($data, 'some text', false, true); print $debug_str; // -------------------------------------------- ?> ---- Server IP: 69.147.83.199 Probable Submitter: 188.193.219.174 ---- Manual Page -- http://php.net/manual/en/function.print-r.php Edit -- https://master.php.net/note/edit/113399 Del: integrated -- https://master.php.net/note/delete/113399/integrated Del: useless -- https://master.php.net/note/delete/113399/useless Del: bad code -- https://master.php.net/note/delete/113399/bad+code Del: spam -- https://master.php.net/note/delete/113399/spam Del: non-english -- https://master.php.net/note/delete/113399/non-english Del: in docs -- https://master.php.net/note/delete/113399/in+docs Del: other reasons-- https://master.php.net/note/delete/113399 Reject -- https://master.php.net/note/reject/113399 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196479) next »