Removing a function at runtime in PHP (without the runkit extension)

前端 未结 9 1454
逝去的感伤
逝去的感伤 2020-12-09 16:33

I know this question seems hacky and weird, but is there a way to remove a function at runtime in PHP?

I have a recursive function declared in a \"if\" block and wan

9条回答
  •  粉色の甜心
    2020-12-09 16:47

    There may be another solution for replacing functions by changing usage of them like this ;

    function function1(){
     echo "1";
    }
    
    function function2(){
     echo "2";
    }
    
    if(FUNCTION_CHOOSER_CONDITION) $the_function = "function2";
    else $the_function="function1";
    $the_function(); //  displays 2 if condition is TRUE;
    

    Maybe this not for you in this situation as you wanted to destroy the function but i though this is right place to talk about replacement of functions.

提交回复
热议问题