Create a instance from a string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chathura86
    New Member
    • May 2007
    • 227

    Create a instance from a string

    hi i want to create an object instance from a string

    i know that the following method works
    Code:
    $className = "Foo";
    $object = new $className();
    but i want to pass parameters as well, number of parameters is not a
    constant and it is a passed as an array

    it there a way to do this, im looking for something like
    call_user_func_ array where you can execute function with parameters as array

    Regards
    Chathura Bamunusinghe
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Originally posted by chathura86
    it there a way to do this, im looking for something like call_user_func_ array where you can execute function with parameters as array
    use call_user_func_ array(), usage see examples.

    Comment

    • chathura86
      New Member
      • May 2007
      • 227

      #3
      found the solution
      thanks for the tip Dormilich

      Regards
      Chathura Bamunusinghe

      Comment

      Working...