Singleton

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shelly

    #1

    Singleton

    I found that in PHP5 the following does not work:

    $a = "Foo";
    $b = $a::getStaticMe thod();

    I've tried {$a}::getStatic Method(); 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
  • Shelly

    #2
    Re: Singleton

    On Jan 24, 5:07 pm, Shelly <sheldo...@thev illages.netwrot e:
    I found that in PHP5 the following does not work:
    >
    $a = "Foo";
    $b = $a::getStaticMe thod();
    >
    I've tried {$a}::getStatic Method(); 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.

    Comment

    • Rik Wasmus

      #3
      Re: Singleton

      On Thu, 24 Jan 2008 23:44:16 +0100, Shelly <sheldonlg@thev illages.net
      wrote:
      On Jan 24, 5:07 pm, Shelly <sheldo...@thev illages.netwrot e:
      >I found that in PHP5 the following does not work:
      >>
      >$a = "Foo";
      >$b = $a::getStaticMe thod();
      >>
      >I've tried {$a}::getStatic Method(); 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.
      Eval is evil.

      I could have sworn it would work as the example BTW, apparantly not.
      Preferable to eval would be:

      $b = call_user_func( array($a,'getSt aticMethod'),$a nd,$some,$argum ents);
      or
      $b =
      call_user_func_ array(array($a, 'getStaticMetho d'),array($and, $some,$argument s));
      --
      Rik Wasmus

      Comment

      Working...