Call a PHP function dynamically

后端 未结 6 1392
[愿得一人]
[愿得一人] 2020-12-18 19:22

Is there a way to call a function through variables?

For instance, I want to call the function Login(). Can I do this:

$varFunction = \"Login\"; //to         


        
6条回答
  •  粉色の甜心
    2020-12-18 19:55

    You can use...

    $varFunction = "Login";
    $varFunction();
    

    ...and it goes without saying to make sure that the variable is trusted.

提交回复
热议问题