call non-static class method with dynamic class name -


right i'm solving problem this:

    switch($action)     {       case "get":          if("sections" == $table){           echo $get->nested();         }          else {           echo $get->elements();         }        break;        case "upd":          if("sections" == $table){           echo $upd->nested();         }          else {           echo $upd->elements();         }        break;     } 

but there must more 'elegant' way right?!

    if("sections" == $table)       call_user_func(array(ucfirst($action), 'nested'));     else        call_user_func(array(ucfirst($action), 'elements')); 

is not working. how solve that?


Comments

Popular posts from this blog

many to many - Django Rest Framework ManyToMany filter multiple values -

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

Java Entity Manager - JSON reader was expecting a value but found 'db' -