How to print variable name and contents
| From: | nntp.charter.net | Date: | Wed, 15 Jun 2005 13:33:48 +0000 |
| Subject: | How to print variable name and contents | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-217045@lists.php.net to get a copy of this message | ||
I want to write a trace procedure and call it with variable names, and I am
having trouble with the syntax. My goal is to have a procedure that will
echo lines such as:
Trace: $myvar="the contents of $myvar
My attempt that didn't work is to write a function:
function my_trace($m){
echo ("\n<br>TRACE: $m = ");
eval("\$t=\"$m\";");
echo($t."<br>\n");
}
and call it with statements like:
my_trace("\$my_var");
my_trace("\$_ENV[\"COMPUTERNAME\"]");
What am I doing wrong, and how should this be done? Also, should I post to
a different group?
Thanks,
Gil Grodsky
ggrodsky@charter.net