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
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
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
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
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);
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
^^^
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
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
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
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
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:
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
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
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
14 matches
Mail list logo