RE: [PHP] Print a variable's name

From: Date: Wed, 05 May 2004 15:23:12 +0000
Subject: RE: [PHP] Print a variable's name
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-185434@lists.php.net to get a copy of this message
Ahbaid Gaffoor wrote: > Thanks Ryan, > > but what I want is to be able to pass any variable to a procedure and > have the variable name and value printed by the procedure. > > Can this be done? > > I'm trying to extend my library of debugging functions/procedures by > having a procedure which can be used to "inspect" a variable whenever > I call it. This is a bit kludgy, but should work: function showvar($varname) { if (!isset($GLOBALS[$varname])) { return; } echo "Now showing: $varname\n"; echo "Value: ".$GLOBALS[$varname]."\n"; } $s1 = "Hello World"; showvar('s1'); HTH

« previous php.general (#185434) next »