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

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

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -