您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

网友原创的PHP模板类

2025/3/21 17:22:34发布17次查看
网友原创的php模板类
以下是php源代码:
tpl_header = null;
            $this->tpl_footer = null;
            $this->tpl_parsing = array();
            $this->tpl_template = ’list.html’;
            $this->tpl_toparse = null;
$this->tpl_parse_string = array();
            $this->tpl_parse_array = array();
$this->tpl_result = null;
            return true;
        }
function parse_template() {
            $this->tpl_parse_string = array();
            $this->tpl_parse_array = array();
            if($this->tpl_header!=null) { array_push($this->tpl_parse_string,$this->tpl_header);array_push($this->tpl_parse_array,’{header}’); }
            if($this->tpl_footer!=null) { array_push($this->tpl_parse_string,$this->tpl_footer);array_push($this->tpl_parse_array,’{footer}’); }
            if(count($this->tpl_parsing)!=1) {
                foreach($this->tpl_parsing as $tpl_key => $tpl_value) {
                    array_push($this->tpl_parse_string,$tpl_value);
                    array_push($this->tpl_parse_array,’{’.$tpl_key.’}’);
                }
            }
            if($this->tpl_template!=null && $this->tpl_toparse==null) {
                $this->tpl_toparse = file_get_contents(root.’./templates/’.$this->tpl_template);
            } 
            $this->tpl_result = str_replace($this->tpl_parse_array,$this->tpl_parse_string,$this->tpl_toparse);
            return $this->tpl_result;
        }
}
?>
用法:
$mdl = new lightpage_template();
    $mdl->tpl_header = ’zzz’;
    $mdl->tpl_footer = ’’;
    $mdl->tpl_parsing = ’’;
    $mdl->tpl_template = ’list.html’;
    echo $mdl->parse_template();
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product