请问如何在PHP中嵌入一个HTML文件
php里面添加html文件,很多时候需要用到!
如添加一个站点统计到网站,如果你的网站全部是php来写的,这时候直接用echo输出统计代码就会出现问题!然后php可以很方便的引入一个html文件,这样就方便多了!
具体操作如下:
在do_footer函数里面利用include即可导入一个html文件
1)修改do_footer函数
function do_footer($credits = true) {
global $globals;
echo "</div><!–#container closed–>\n";
include("hugwww-footer.html");
if($credits) @do_credits();
do_js_from_array($globals['post_js']);
// warn warn warn
// dont do stats of password recovering pages
@include(‘ads/stats.inc’);
printf("\n<!–Generated in %4.3f seconds–>\n", microtime(true) – $globals['start_time']);
echo "</div></body></html>\n";
}
2)将统计代码写入hugwww-footer.html文件
完成!
五月 1st, 2010 at 11:20
好,收藏了!正有用得着这个!