Calling a method with an array value in PHP

Posted by Saif Bechan on Stack Overflow See other posts from Stack Overflow or by Saif Bechan
Published on 2010-05-13T19:48:35Z Indexed on 2010/05/13 19:54 UTC
Read the original article Hit count: 149

Filed under:
|

I have a class like this

class someclass{
  public function somemethod(){}
}

Now I have an array:

$somearray['someclass']  = new someclass();
$somearray['somemethod'] = 'somemethod';

How can I fire them, I tried the following:

$somearray['someclass']->$somearray['somemethod']();

usign this I get the following error:

Fatal error: Method name must be a string in ......................

Anyone have an idea on how to do this?

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays