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

cron - how to properly run Python script with crontab on every system startup -

elasticsearch - Is the order of operations guaranteed in a bulk update? -

Slow performance first queries on SQL Azure -