Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

Use of assignment to $[ is deprecated at /usr/local/sbin/apxs line 86. , wwwxxx vim, mysql closing table and opening table, 800c5000, setgid operation not permitted, pciehp: acpi_pciehprm on IBM, WWWXXX.DBF, 078274121, info0a ip, should prodicers of software_based services be held liable or not liable for economic injuries

Links

XODOX
Impressum

#1: Singleton

Posted on 2008-01-24 23:07:50 by 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

Report this message

#2: Re: Singleton

Posted on 2008-01-24 23:44:16 by Shelly

On Jan 24, 5:07 pm, Shelly <sheldo...@thevillages.net> 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.

Report this message

#3: Re: Singleton

Posted on 2008-01-25 00:08:30 by luiheidsgoeroe

On Thu, 24 Jan 2008 23:44:16 +0100, Shelly <sheldonlg@thevillages.net> =

wrote:

> On Jan 24, 5:07 pm, Shelly <sheldo...@thevillages.net> 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

Report this message