PHP performance hampered by require()

前端 未结 5 575
旧时难觅i
旧时难觅i 2021-01-19 18:25

I ran my code through xdebug profiler and saw more than 30 percent of the time is spent on the require() calls. What is the best way to improve on this? I saw some posts a

5条回答
  •  梦毁少年i
    2021-01-19 18:39

    Make sure your includes use absolute instead of relative paths. Easiest way to do this is by prepending your paths with

    dirname(__FILE__)  // for php < 5.3
    __DIR__            // for php >= 5.3 
    

提交回复
热议问题