Re: [PHP] name of the variable

2007-03-12 Thread Richard Lynch
On Fri, March 9, 2007 4:27 am, Cefull Lo wrote:
 Hi everyone,
 Is there any function that return the name of the variable??
 i.e.

 $foo='abc';
 $bar=somefunc($foo); // $bar='foo' here

No.

And there cannot be, as any given variable could have multiple
references and be passed around through several functions, getting a
different name each time.

You probably should be putting 'foo' and 'abc' into an array instead.

$foobar['foo'] = 'abc';

You can then address 'foo' and 'abc' with various array functions.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] name of the variable

2007-03-09 Thread Cefull Lo

Hi everyone,
Is there any function that return the name of the variable??
i.e.

$foo='abc';
$bar=somefunc($foo); // $bar='foo' here

Thanks


--
-BEGIN GEEK CODE BLOCK-
Version: 3.1
GSC d- s:++ a- C++ UL/B+++$ !P L+++
E--- W+ N o-- K? w++ O? M- V- PS PE++(-) Y+
PGP++@ t 5 X R$ tv- b+++ DI++ D++
G++@ e h*--- r-- z?
-END GEEK CODE BLOCK--


Re: [PHP] name of the variable

2007-03-09 Thread Jochem Maas
Cefull Lo wrote:
 Hi everyone,
 Is there any function that return the name of the variable??
 i.e.
 
 $foo='abc';
 $bar=somefunc($foo); // $bar='foo' here

no - and if you think you need this then there is something very wrong with you 
code,
it's completely backward-assed and you need to rethink what you are doing.

maybe if you explain the exact nature of your problem we could show you
a better way of tackling it so that you are no longer in need of a function
that 'tells you the name of the varable'

 
 Thanks
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] name of the variable

2007-03-09 Thread Ólafur Waage

I found this on the zend forums. Hope it helps.

function Dump($var) {
if (key_exists($var, $GLOBALS)) {
echo pre$$var:\n;
var_dump($GLOBALS[$var]);
echo \n/pre\n;
}
else
echo span class='error'No variables named 
em$$var/em!/span\n;
}


- Ólafur W

2007/3/9, Cefull Lo [EMAIL PROTECTED]:


Hi everyone,
Is there any function that return the name of the variable??
i.e.

$foo='abc';
$bar=somefunc($foo); // $bar='foo' here

Thanks


--
-BEGIN GEEK CODE BLOCK-
Version: 3.1
GSC d- s:++ a- C++ UL/B+++$ !P L+++
E--- W+ N o-- K? w++ O? M- V- PS PE++(-) Y+
PGP++@ t 5 X R$ tv- b+++ DI++ D++
G++@ e h*--- r-- z?
-END GEEK CODE BLOCK--