Singleton
am 24.01.2008 23:07:50 von Shelly
I found that in PHP5 the following does not work:
$a = "Foo";
$b = $a::getStaticMethod();
I've tried {$a}::getStaticMethod(); and a few other things. Looking
in the manual, Example 2 is just this. However, a user posted on Jan,
4 that this doesn't work (just as I found out today). Is this a bug?
Does anyone have a work-around? (I am not looking forward to doing an
eval instead).
Shelly
Re: Singleton
am 24.01.2008 23:44:16 von Shelly
On Jan 24, 5:07 pm, Shelly wrote:
> I found that in PHP5 the following does not work:
>
> $a = "Foo";
> $b = $a::getStaticMethod();
>
> I've tried {$a}::getStaticMethod(); and a few other things. Looking
> in the manual, Example 2 is just this. However, a user posted on Jan,
> 4 that this doesn't work (just as I found out today). Is this a bug?
>
> Does anyone have a work-around? (I am not looking forward to doing an
> eval instead).
>
> Shelly
An eval worked.
Re: Singleton
am 25.01.2008 00:08:30 von luiheidsgoeroe
On Thu, 24 Jan 2008 23:44:16 +0100, Shelly =
wrote:
> On Jan 24, 5:07 pm, Shelly wrote:
>> I found that in PHP5 the following does not work:
>>
>> $a =3D "Foo";
>> $b =3D $a::getStaticMethod();
>>
>> I've tried {$a}::getStaticMethod(); and a few other things. Lookin=
g
>> in the manual, Example 2 is just this. However, a user posted on Jan=
,
>> 4 that this doesn't work (just as I found out today). Is this a bug?=
>>
>> Does anyone have a work-around? (I am not looking forward to doing a=
n
>> eval instead).
>>
>> Shelly
>
> An eval worked.
Eval is evil.
I could have sworn it would work as the example BTW, apparantly not. =
Preferable to eval would be:
$b =3D call_user_func(array($a,'getStaticMethod'),$and,$some,$argum ents)=
;
or
$b =3D =
call_user_func_array(array($a,'getStaticMethod'),array($and, $some,$argum=
ents));
-- =
Rik Wasmus