need help w/ unfamiliar syntax

need help w/ unfamiliar syntax

am 11.04.2010 20:30:01 von lala

Hi all,

I've wasted two days trying to find this in the documentation. Google
is no help here either; they only index text.

While looking at some code using objects I came across this:

$this->{$spec}

The example works with or without the curly braces, but I know they
aren't there for just for decoration ;)

Will somebody be so kind as to point me where in the docs this syntax is
explained?

tia

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

Re: need help w/ unfamiliar syntax

am 11.04.2010 20:43:41 von Daniel Egeberg

On Sun, Apr 11, 2010 at 20:30, lala wrote:
> Hi all,
>
> I've wasted two days trying to find this in the documentation.  Goog=
le is no
> help here either; they only index text.
>
> While looking at some code using objects I came across this:
>
>    $this->{$spec}
>
> The example works with or without the curly braces, but I know they aren'=
t
> there for just for decoration ;)
>
> Will somebody be so kind as to point me where in the docs this syntax is
> explained?
>
> tia

It's documented here:
http://php.net/manual/en/language.variables.variable.php

It works for function and class names as well.

--=20
Daniel Egeberg

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

Re: need help w/ unfamiliar syntax

am 12.04.2010 03:35:50 von kranthi

guess you are looking for
http://www.php.net/manual/en/language.types.string.php#langu age.types.string.parsing

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

Re: need help w/ unfamiliar syntax

am 12.04.2010 04:21:22 von Robert Cummings

Daniel Egeberg wrote:
> On Sun, Apr 11, 2010 at 20:30, lala wrote:
>> Hi all,
>>
>> I've wasted two days trying to find this in the documentation. Google is no
>> help here either; they only index text.
>>
>> While looking at some code using objects I came across this:
>>
>> $this->{$spec}
>>
>> The example works with or without the curly braces, but I know they aren't
>> there for just for decoration ;)
>>
>> Will somebody be so kind as to point me where in the docs this syntax is
>> explained?
>>
>> tia
>
> It's documented here:
> http://php.net/manual/en/language.variables.variable.php
>
> It works for function and class names as well.

The style used above is superfluous since no additional operations are
being done within the braces and so the braces are redundant. This is
why it works either way.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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