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

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

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -