Re: [PHP] Variable names
> function somefunction($myvar) { > do something... > ... > ... $variablealacon = "\$myvar"; return $variablealacon; > } > > $varname = somefunction($myvar); > echo "$varname"; kodrik a écrit : > > function somefunction($myvar) { > > do something... > > ... > > ... > > return \$myvar; > > } > > > > $varname = somefunction($myvar); > > echo "$varname"; > > That won't work, because you escaped the $ sign, the variable won't get > processed and the name returned will be the one of the variable as it is > declared in the function, always the same. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable names
> function somefunction($myvar) { > do something... > ... > ... > return \$myvar; > } > > $varname = somefunction($myvar); > echo "$varname"; That won't work, because you escaped the $ sign, the variable won't get processed and the name returned will be the one of the variable as it is declared in the function, always the same. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable names
Hello Kodrik, I would do the following code. Excuse me if there are many mistakes. I am only a newbie. So: function somefunction($myvar) { do something... ... ... return \$myvar; } $varname = somefunction($myvar); echo "$varname"; Hope it helps you SR kodrik a écrit : > If I have a variable, how do I extract the name of the variable. > > In principle: > > $varname=somefunction($myvar); > > The value of $varname is then "myvar" > > How do I do it? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php