[PHP] Can i take the variable name in a function?

2006-10-11 Thread Jônata Tyska Carvalho
How can i take the variable name inside a function, ex: definition: function example( $ex ){ echo Variable Name is $ex ; // how to do this? } use: example($ball); output: Variable Name is ball; another: example($sportCar); output: Variable Name is sportCar; is that possible? --

Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Jochem Maas
Jônata Tyska Carvalho wrote: How can i take the variable name inside a function, ex: definition: function example( $ex ){ echo Variable Name is $ex ; // how to do this? } use: example($ball); output: Variable Name is ball; another: example($sportCar); output: Variable

Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Andy Hultgren
Would something like this work? Definition: function example($$ex) { echo Variable Name is $ex; } example($ball); I'm fairly new to php and not so familiar with variable variables, but I thought I'd throw it out there as a thought! Andy On 10/11/06, Jochem Maas [EMAIL PROTECTED] wrote:

Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Jochem Maas
Andy Hultgren wrote: Would something like this work? did you try it? ;-) it won't work Definition: function example($$ex) { echo Variable Name is $ex; } example($ball); I'm fairly new to php and not so familiar with variable variables, but I thought I'd throw it out there

Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Andy Hultgren
u no... I suppose I should have though! :) On 10/11/06, Jochem Maas [EMAIL PROTECTED] wrote: Andy Hultgren wrote: Would something like this work? did you try it? ;-) it won't work Definition: function example($$ex) { echo Variable Name is $ex; } example($ball); I'm

Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Andy Hultgren
Check this out: http://www.php.net/manual/en/functions.arguments.php Specifically this example: Making arguments be passed by reference By default, function arguments are passed by value (so that if you change the value of the argument within the function, it does not get changed outside of

Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Eric Butera
On 10/11/06, Andy Hultgren [EMAIL PROTECTED] wrote: ?php function add_some_extra($string) { $string .= 'and something extra.'; } $str = 'This is a string, '; add_some_extra($str); echo $str;// outputs 'This is a string, and something extra.' ? I think that does what you want? In the

Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Eric Butera
On 10/11/06, Paul Scott [EMAIL PROTECTED] wrote: On Wed, 2006-10-11 at 13:19 -0400, Eric Butera wrote: In the add_some_extra example you gave he wants the named value of the passed parameter which is $str. Isn't that what the Reflection API is there for? --Paul All Email originating

Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Paul Scott
On Wed, 2006-10-11 at 13:19 -0400, Eric Butera wrote: In the add_some_extra example you gave he wants the named value of the passed parameter which is $str. Isn't that what the Reflection API is there for? --Paul All Email originating from UWC is covered by disclaimer

Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Richard Lynch
On Wed, October 11, 2006 9:58 am, Jônata Tyska Carvalho wrote: How can i take the variable name inside a function, ex: definition: function example( $ex ){ echo Variable Name is $ex ; // how to do this? } use: example($ball); output: Variable Name is ball; another:

Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Richard Lynch
On Wed, October 11, 2006 12:19 pm, Eric Butera wrote: On 10/11/06, Andy Hultgren [EMAIL PROTECTED] wrote: ?php function add_some_extra($string) { $string .= 'and something extra.'; } $str = 'This is a string, '; add_some_extra($str); echo $str;// outputs 'This is a string, and

Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Richard Lynch
On Wed, October 11, 2006 2:21 pm, Richard Lynch wrote: If you really really really know what you are doing, you can do this: And if you make no typos like I just did... :-) function example($name){ // global $name; //Whoops! global $$name; //note the TWO $ symbols! echo The variable

Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Jônata Tyska Carvalho
i know what i want to do, and im not a rookie in php. example of a use: debug($vetNames); output: The variable vetNames has the follow properties: key1 = value1, key2 = value2 just one example. need it for another things. On 10/11/06, Richard Lynch [EMAIL PROTECTED] wrote: On

Re: [PHP] Can i take the variable name in a function?

2006-10-11 Thread Robert Cummings
On Wed, 2006-10-11 at 19:02 -0300, Jônata Tyska Carvalho wrote: i know what i want to do, and im not a rookie in php. example of a use: debug($vetNames); output: The variable vetNames has the follow properties: key1 = value1, key2 = value2 Example: ?php function fooA( $fooA ) {