nested functions in php throws an exception when the outer is called more than once

前端 未结 5 666
执念已碎
执念已碎 2021-01-19 18:35

lest assume that i have the following

function a(){
  function b(){}
}
a(); //pass
a(); //error

why in the second call an exception is thr

5条回答
  •  生来不讨喜
    2021-01-19 19:21

    It's because you're calling a() in a global scope. Add a function_exists call to make the above code work, but really there are few scenarios where you should really do something like this.

提交回复
热议问题