RE: [PHP] ${}
| From: | Buesching, Logan J | Date: | Wed, 25 Apr 2007 13:53:58 +0000 |
| Subject: | RE: [PHP] ${} | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-253705@lists.php.net to get a copy of this message | ||
Heh, lucky me I was just looking into that earlier today.
http://us.php.net/manual/en/language.types.string.php
Around the "Simple Syntax" area.
-Logan
-----Original Message-----
From: Robert Cummings [mailto:robert@interjinn.com]
Sent: Wednesday, April 25, 2007 9:42 AM
To: Man-wai Chang
Cc: php-general@lists.php.net
Subject: Re: [PHP] ${}
On Wed, 2007-04-25 at 21:23 +0800, Man-wai Chang wrote:
> where can I find the documentation about this "symbol"?
Maybe in the documentation? A cursory glance from me though didn't turn
anything up. Either way I can inform you of the purpose...
The following two expression have the same result:
$foo = 5;
${'foo'} = 5;
The difference being that the code between { and } is first evaluated to
determine the name of the variable. $foo is preferred and faster but
there may be the odd time when you find doing something like the
following useful:
${'foo_'.$i} = $someValue;
So let's imagine $i = 3, then a variable called $foo_3 has been created
and can even be accessed as $foo_3.
If you are familiar with variable variables then you may be aware that
the above can also be achieved as follows:
$name = 'foo_'.$i;
$$name = $someValue;
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php