开发者

Breaking up a page and use require in PHP

开发者 https://www.devze.com 2023-03-27 04:18 出处:网络
I´m working on a new web page, and the pages gets extremly开发者_开发百科 long with thousands of rows. So I´m planning on breaking up the page´s different sections into several pages and then displ

I´m working on a new web page, and the pages gets extremly开发者_开发百科 long with thousands of rows. So I´m planning on breaking up the page´s different sections into several pages and then display them using require_once() or require() in the main page. My question is if this will affect the speed when the pages load? It feels that way since it has to open up and load several pages. But maybe I´m wrong?


Don't worry about it. The difference is rarely important. require_once() is slower than require() if you need to choose.

Install apc (Alternative PHP Cache) and require() is just as fast as including it directly (but require_once() is not as good).

http://pecl.php.net/package/APC


  1. Don't think about performance until you have actual performance problem. Just split it as is most convenient for maintenance (i.e. split those pieces that will be reused on multiple pages).
  2. The other processing probably takes much more time than any possible penalty incurred by using require(). If not, you shouldn't be using PHP in the first place (i.e. if it's otherwise static, use server-side includes).
0

精彩评论

暂无评论...
验证码 换一张
取 消