PHP - Function inside a Function. Good or bad?

后端 未结 4 1480
有刺的猬
有刺的猬 2020-12-30 01:41

I would like to know if it is a good thing to define a function inside another function in PHP. Isn\'t it better to define it before the function (and not inside) in terms o

4条回答
  •  渐次进展
    2020-12-30 02:11

    I think you should care more about maintenability, and less about performance, especially in that kind of situation, where the difference in performances is probably not that big between the two solutions, while the difference in maintenability seems important.

    Like Donald Knuth said :

    We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.

    This is quite true, in this situation ;-)

提交回复
热议问题