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