Breaking up a page and use require in PHP
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
- 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).
- 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).
精彩评论