php插入html文件

php插入html文件,第1张

PHP插入或者引入外部文件函数有:require,require_once,include,include_once等;插入HTML文件使用其中任意一个函数都可以;

比如zhidao.php要插入zd.html文件,示例如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html charset=UTF-8">

<title>HTML</title>

</head>

<body>

<font  color="red">html部分</font>

</body>

</html> <?php

echo "-----------插入的HTML内容如下----------------"

echo "<br/>"

require  'test.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'])

2)将统计代码写入hugwww-footer.html文件完成!


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/7191395.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-02
下一篇 2023-04-02

发表评论

登录后才能评论

评论列表(0条)

保存