douchen2595 2015-06-21 01: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 02: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条)
编辑
预览

报告相同问题?