Re: ${}

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




----- Original Message ----- From: "Man-wai Chang" <toylet.toylet@xxxxxxxxx>
To: <php-general@xxxxxxxxxxxxx>
Sent: Wednesday, April 25, 2007 3:23 PM
Subject:  ${}



where can I find the documentation about this "symbol"?



It is one of those almost hidden treasures that is documented, a little bit here and there, but it doesn't have a page on its own.

It is used to dissambiguate complex variables, specially when embedded within double-quoted strings, so the interpreter knows how far does the variable name and its parts go and when the rest of the string goes. For example, if withing a double-quoted or heredoc string, the variable name is immediately followed by a text or number without any spaces in between, the interpreted can't know whether those characters are part of the variable name or not. Also, when you want to refer to an array element or an object property, the resulting expression might get somewhat more complicated and there might be ambiguities as to how far does the variable goes and where the rest of the string goes.

It might also be used to generate variable names on the fly, ${'variable' . $i} will produce the contents of $variable0 for $i = 0.

I think it was also used to refer to individual characters within a string as if it was a character array, but that is deprecated in favour of square brackets.

Satyam


--
 .~.   Might, Courage, Vision, SINCERITY. http://www.linux-sxs.org
/ v \  Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Ubuntu 6.10)  Linux 2.6.20.7
 ^ ^   21:22:01 up 6 days 2:08 0 users load average: 1.00 1.00 1.00
news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk

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



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.463 / Virus Database: 269.6.0/775 - Release Date: 24/04/2007 17:43



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux