Re: A bit stuck with $$

From: Date: Fri, 27 Aug 2004 04:56:29 +0000
Subject: Re: A bit stuck with $$
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-194895@lists.php.net to get a copy of this message
* Thus wrote Neil: > > > Not sure if its me or the configuration of PHP variable variables are rather standard and dont have any configuration settings. > > I have played around with this bit of code from operators part of the > manual and this does not appear to work, well for me at least. > > $foo = "test"; > $$bar = "this is"; > > echo "${$bar} $foo"; // prints "this is test" Everything is working so far as expected > Note: it is the same as > echo "$test $foo"; // ***** for me it only prints out "test" You are throwing me here.. the problem seems to be that $test hasn't been assign. By using your examples I can make $test actually be a value by doing this with the variable variable: $$foo = 'avalue'; // $test is assinge 'avalue' Is equivalent as doing: $test = 'avalue'; // $test is assinge 'avalue' And thus, without the actual $test assignment: echo "$test $foo"; will result in: "avalue test" HTH, Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid!

« previous php.general (#194895) next »