__get/__set/__call performance questions with PHP

后端 未结 4 837
时光取名叫无心
时光取名叫无心 2020-12-06 19:23

I have a custom-built MVC PHP framework that I am in the process of rewriting and had a question about performance and magic methods. With the model portion of the framewor

4条回答
  •  一向
    一向 (楼主)
    2020-12-06 20:06

    Purely from my experience, it does add a quite a lot over overhead. On a page with about 4000 __get's (yes, there was quite a lot of data on that page) performance was quite measurably slower, to the point it became unacceptable. I threw away all __set's & __get's for variables which wouldn't require other data to be altered or external dependancies (like foreign keys) to be checked, after which the time to generate that page was about 15% of the time it took before.

提交回复
热议问题