您好,欢迎访问一九零五行业门户网

网友原创的PHP模板类

网友原创的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();
其它类似信息

推荐信息