Re: Re[2]: [PHP] Name of the variable
| From: | Matthew Leingang | Date: | Wed, 18 Oct 2000 22:05:14 +0000 |
| Subject: | Re: Re[2]: [PHP] Name of the variable | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-20994@lists.php.net to get a copy of this message | ||
Dear Coolio,
Mostly, you can't, unless the variables you want the names of are also
stored in one of the hashes like $HTTP_POST_VARS, $HTTP_GET_VARS,
$GLOBALS, etc. Then they are just the keys.
So you could have:
<?php
while (list($key,$val) = each($GLOBALS)) {
echo "\$$key = '$val'<br>\n";
}
?>
to see all the global variables.
HTH,
Matt
----------------------------------------------------------------
Matthew Leingang http://www.math.rutgers.edu/
Rutgers University leingang@math.rutgers.edu
Department of Mathematics "This signature needs no quote."
On Wed, 18 Oct 2000, coolio wrote:
> Hola Philip,
>
> Wednesday, October 18, 2000, 4:00:22 PM, escribistes:
>
> PO> Hi coolio-
> PO> You can print or echo them (I will use echo) :
> PO> <?
> PO> echo $this_is_a_variable;
> PO> ?>
> PO> or
> PO> <?
> PO> echo "Hi, my name is $this_is_a_variable";
> PO> ?>
> PO> but not :
> PO> <?
> PO> echo '$this_is_a_variable';
> PO> ?>
>
> PO> see : http://www.php.net/manual/language.variables.php
> PO> see : http://www.zend.com/zend/tut/using-strings.php
>
> I know how to print or echo the content of a variable.
> What I need to know, is how to print the name of the variable.
>
> If I got $variable1 = 'contenido1' and $otra_variable = 'otro
> contenido', I want to show
> first variable: variable1
> second variable: otra_variable
>
> I dont care about the content of the variable.
>
> --
> bye!,
> coolio coolio@mdq.com
>
>
>
> [ Part 155: "Included Message" ]
>