You are here: Re: How to print variable name and contents « PHP « IT news, forums, messages
Re: How to print variable name and contents

Posted by "Sergey" on 06/16/05 15:04

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

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

""nntp.charter.net"" <grodsky@yahoo.com> ΣΟΟΒέΙΜ/ΣΟΟΒέΙΜΑ Χ ΞΟΧΟΣΤΡΘ
ΣΜΕΔΥΐέΕΕ: news:17.BE.20931.3EE20B24@pb1.pair.com...
>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

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация