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

前端 未结 9 1452
逝去的感伤
逝去的感伤 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:56

    I agree with Alix. You can, however, avoid the function being called from anywhere else by getting rid of the function. Rewrite the recursive function as an iterative loop. You'll have the added benefit of reduce memory usage.

    UPDATE: with your code example, I'm not sure why you feel the need to prevent this function from being called again. It simply formats some strings in an array recursively... again, you could do this iteratively and avoid having a function in the first place. Otherwise, just leave it there and don't call it again.

提交回复
热议问题