note 96979 added to function.var-dump

From: Date: Thu, 25 Mar 2010 18:15:43 +0000
Subject: note 96979 added to function.var-dump
Groups: php.notes 
Request: Send a blank email to php-notes+get-167414@lists.php.net to get a copy of this message
If you want some fancy var_dump, here it goes: [CODE] function dbg($vars, $die = 0) { $vars = explode(',', $vars); if(sizeof($vars)) foreach($vars as $var) { $varname = trim($var); if($varname[0] == "$") $varname = substr($varname, 1); global ${$varname}; $varvalue = ${$varname}; if(is_Array($varvalue)) $output = print_r($varvalue, true); else $output = $varvalue; ob_start(); var_dump($varvalue); $varDump=ob_get_contents(); ob_end_clean(); echo '<pre style="background-color:#eeeeee; margin-bottom: 5px; border:3px blue double"><b style="color:#ff0000"><b>Standard output of [<font style="color:green">$' . $varname . '</font>] :</b><br>' . $output . '<hr><b>VarDump of [<font style="color:green">$' . $varname . '</font>] :</b><br>' . htmlspecialchars($varDump, ENT_QUOTES) . '</pre>'; } if($die) die(); // :) } [/CODE] USAGE: $a = array(1, 2, 3); $b = 'test'; $c = rand(0,5); dbg('a,b,c'); Or if after debbuging die() is needed: dbg('a,b,c', true); ---- Server IP: 69.147.83.197 Probable Submitter: 86.104.196.147 ---- Manual Page -- http://www.php.net/manual/en/function.var-dump.php Edit -- https://master.php.net/note/edit/96979 Del: integrated -- https://master.php.net/note/delete/96979/integrated Del: useless -- https://master.php.net/note/delete/96979/useless Del: bad code -- https://master.php.net/note/delete/96979/bad+code Del: spam -- https://master.php.net/note/delete/96979/spam Del: non-english -- https://master.php.net/note/delete/96979/non-english Del: in docs -- https://master.php.net/note/delete/96979/in+docs Del: other reasons-- https://master.php.net/note/delete/96979 Reject -- https://master.php.net/note/reject/96979 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#167414) next »