在PHP中拆分页面并使用require [英] Breaking up a page and use require in PHP

查看:110
本文介绍了在PHP中拆分页面并使用require的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个新的网页,并且页面变得非常长,成千上万行.因此,我计划将页面的不同部分分成几个页面,然后在主页中使用require_once()或require()显示它们.我的问题是,这是否会影响页面加载时的速度?感觉就是这样,因为它必须打开并加载多个页面.但是也许我错了?

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?

推荐答案

  1. 在您遇到实际的性能问题之前,请不要考虑性能.只需将其拆分为最便于维护的方式(即拆分那些将在多页上重复使用的部分).
  2. 与使用require()可能引起的任何损失相比,其他处理可能花费更多的时间.如果不是这样,那么您一开始就不应该使用PHP(即如果它是静态的,请使用服务器端包含).
  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).

这篇关于在PHP中拆分页面并使用require的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆