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 ?php $x = 5; ? 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

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 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 the

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 malformed XML

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 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? For

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

2005-07-18 Thread Daevid Vincent
That won't work. Then I will get what the VALUE of $bar is set to. I want the actual text bar. Basically everything after the $ -- ie. The NAME of the VARIABLE, not it's contents. The closest I've come so far is to do this. Function myname($foo) { echo variable named $foo has the

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

2005-07-18 Thread Rob Agar
hi Daevid FWIW, I was trying to do the exact same thing a while back, and came to the conclusion that it wasn't possible. Rob -Original Message- From: Daevid Vincent [mailto:[EMAIL PROTECTED] Sent: Tuesday, 19 July 2005 11:28 AM To: php-general@lists.php.net Subject: [PHP] Is

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 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 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

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

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