RE: [PHP] Is there a way to get a variable name as a string?

2005-07-22 Thread Daevid Vincent
> He wants a function that, if you put in $x, you get out 'x' > > For *ANY* $variable. > > There is no such function. > Usually the person asking it is doing something very > newbie-ish, and very wrong. Actually it's not either... Since you can't easily debug when generating XML, as malforme

RE: [PHP] Is there a way to get a variable name as a string?

2005-07-22 Thread Daevid Vincent
> What I was thinking with debug_backtrace() is that you could get the > information for the function that called the function you want the > variable name for, *reducing* the likelyhood of duplicate values, but > admitedly not eliminating it. > > You could also pass the name of the variable to

Re: [PHP] Is there a way to get a variable name as a string?

2005-07-22 Thread Edward Vermillion
Richard Lynch wrote: [snip] PS It's true that your variable could/would/should appear in debug_backtrace, but how would you pick it out from all the other variables that would appear in your debug_backtrace? For that matter, it's in $_GLOBALS, but how would you pick it out? You could print

Re: [PHP] Is there a way to get a variable name as a string?

2005-07-22 Thread Richard Lynch
On Mon, July 18, 2005 8:24 pm, Ryan A said: > I didnt totally understand you q in the beginning (and still dont fully), > but He wants a function that, if you put in $x, you get out 'x' For *ANY* $variable. There is no such function. Usually the person asking it is doing something very ne

Re: [PHP] Is there a way to get a variable name as a string?

2005-07-19 Thread Burhan Khalid
Rasmus Lerdorf wrote: Daevid Vincent wrote: Is there a way to get the name of a variable as a string? For example... Nope, not possible. Well ob_start(); echo '$var'; $contents = ob_get_contents(); ob_end_clean(); echo 'Variable Name is : '.substr($contents,strpos($contents,'$')+1);

Re: [PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Tyler Kiley
function named_print($var_name) { return "echo 'the variable named $var_name is set to ' . \$var_name;" } eval(named_print($foo)); ;-) Tyler -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Edward Vermillion
Edward Vermillion wrote: Rasmus Lerdorf wrote: Daevid Vincent wrote: Is there a way to get the name of a variable as a string? For example... Nope, not possible. -Rasmus Wouldn't the name of the variable show up in a var_dump()? It would be messy, but if it's there... Actually I me

Re: [PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Edward Vermillion
Rasmus Lerdorf wrote: Daevid Vincent wrote: Is there a way to get the name of a variable as a string? For example... Nope, not possible. -Rasmus Wouldn't the name of the variable show up in a var_dump()? It would be messy, but if it's there... -- PHP General Mailing List (http://www.php

Re: [PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Ryan A
I didnt totally understand you q in the beginning (and still dont fully), but > > Is there a way to get the name of a variable as a string? For example... > Nope, not possible. > -Rasmus the man has spoken :-D -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

Re: [PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Rasmus Lerdorf
Daevid Vincent wrote: > Is there a way to get the name of a variable as a string? For example... Nope, not possible. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Rob Agar
t; Subject: [PHP] Is there a way to get a variable name as a string? > > > Is there a way to get the name of a variable as a string? For > example... > > Function myname ($foo) > { > echo "the variable name passed in is ".realname($foo); > } >

RE: [PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Daevid Vincent
echo "variable named $foo has the contents $$foo"; } Myname('bar'); Which is pretty lame. > -Original Message- > From: Ryan A [mailto:[EMAIL PROTECTED] > Sent: Monday, July 18, 2005 6:57 PM > To: [EMAIL PROTECTED] > Cc: php > Subject: Re: [PHP] Is

Re: [PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Ryan A
Maybe something like: Function myname ($foo) { $return_value="the variable name passed in is ".$foo; return $return_value; } echo myname($bar); Just a guess. On 7/19/2005 3:27:57 AM, Daevid Vincent ([EMAIL PROTECTED]) wrote: > Is there a way to get the name of a variable as a string? F

[PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Daevid Vincent
Is there a way to get the name of a variable as a string? For example... Function myname ($foo) { echo "the variable name passed in is ".realname($foo); } myname($bar); I want to see printed out: "the variable name passed in is bar"