How to call a function from a string stored in a variable?

后端 未结 16 2277
予麋鹿
予麋鹿 2020-11-22 10:16

I need to be able to call a function, but the function name is stored in a variable, is this possible? e.g:

function foo ()
{
  //code here
}

function bar ()
{
          


        
16条回答
  •  北海茫月
    2020-11-22 11:05

    I dont know why u have to use that, doesnt sound so good to me at all, but if there are only a small amount of functions, you could use a if/elseif construct. I dont know if a direct solution is possible.

    something like $foo = "bar"; $test = "foo"; echo $$test;

    should return bar, you can try around but i dont think this will work for functions

提交回复
热议问题