Re: How to print variable name and contents

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You can use $$var constuction, what display name of $var

function my_trace($var){
echo $$var.'='.$var.'<br>';
 }

""nntp.charter.net"" <grodsky@xxxxxxxxx> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ 
ÓÌÅÄÕÀÝÅÅ: news:17.BE.20931.3EE20B24@xxxxxxxxxxxxxxx
>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@xxxxxxxxxxx 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux