Calling class method of variable class.

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

    Calling class method of variable class.

    Yes, it's the week of OO here in c.l.php

    If I want to call the method a class (not an object), one normally uses:
    classname::meth od();
    which works fine.

    However, what if I don't know the classname yet?
    $classname::met hod();
    doesn't work, neither does
    {$classname}::m ethod();

    I've got solved it like this now:
    call_user_func( array($classnam e,'method'));

    But I really wonder wether this is a good way to do it.

    Grtz,
    --
    Rik Wasmus


  • Richard Levasseur

    #2
    Re: Calling class method of variable class.


    Rik wrote:
    Yes, it's the week of OO here in c.l.php
    >
    If I want to call the method a class (not an object), one normally uses:
    classname::meth od();
    which works fine.
    >
    However, what if I don't know the classname yet?
    $classname::met hod();
    doesn't work, neither does
    {$classname}::m ethod();
    >
    I've got solved it like this now:
    call_user_func( array($classnam e,'method'));
    >
    But I really wonder wether this is a good way to do it.
    >
    Grtz,
    --
    Rik Wasmus
    Yes, thats the correct way. Its called a callback.

    Comment

    Working...