Re: A bit stuck with $$

From: Date: Fri, 27 Aug 2004 05:11:32 +0000
Subject: Re: A bit stuck with $$
Groups: php.general 
Request: Send a blank email to php-general+get-194899@lists.php.net to get a copy of this message
For me echo "$test ------ $foo"; results in avalue ------ Neil At 02:56 PM 27/08/2004, Curt Zirzow wrote:
* 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! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Regards Chester Cairns -------------------------------------------------------------

« previous php.general (#194899) next »