我们有时候需要在php文件中引用模板,举个例子,在会员中心的模板文件中,用include是无法直接引用前台的页面文件,如果我们要饮用,怎么操作呢?
首先打开/include/common.func.php文件,加入一个函数
function pasterTempletDiy($path)
{
require_once(DEDEINC."/arc.partview.class.php");
global $cfg_basedir,$cfg_templets_dir;
$tmpfile = $cfg_basedir.$cfg_templets_dir."/".$path;//模版文件的路径
$dtp = new PartView();
$dtp->SetTemplet($tmpfile);
$dtp->Display();
}
自定义genban.php文件,内容如下:
<?php
require_once("../../include/common.inc.php");
?>
读取公共文件,就使用:
<?php pasterTempletDiy("default/head.htm");?>
本网刊登的文章均仅代表作者个人观点,并不代表本网立场。文中的论述和观点,敬请读者注意判断。
本文地址:http://www.xlkjgs.com/notes/web/12653.html