douchen2595 2015-06-21 09:44
浏览 232
已采纳

html提取页眉和页脚来分隔文档

I have several html documents which share the same header and footer and would like to extract header and footer to separate html files and include them to other html documents.

The idea is very simple: when I change something in header, the change has to be made on all pages.

Until now I used PHP include function. But I have read some articles that this has impact on performance.

What is the best way to do this for clean html pages ?

Is the PHP the way to go ?

If it is, should I insert the whole html content into PHP echo ?

  • 写回答

2条回答 默认 最新

  • douliang6563 2015-06-21 10:02
    关注

    There isn't really a good way doing it in pure HTML, since iframe or an ajax-request using Javascript wouldn't be a good solution here.

    I would say the best way is to use the PHP include or PHP require-function:

    http://php.net/manual/en/function.include.php http://php.net/manual/en/function.require.php

    You won't see any performance issues. Remember that include is a little bit faster than include_once, since include_once will have to make an extra check if the file has already been included.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看