国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

網友原創的PHP模板類

2024-05-04 23:05:21
字體:
來源:轉載
供稿:網友

網友原創的php模板類

以下是php源代碼:
<?php
    class lightpage_template {
    
        var $tpl_header;
        var $tpl_footer;
        var $tpl_parsing;
        var $tpl_template;
        var $tpl_dirname;
        
        var $tpl_parse_string;
        var $tpl_parse_array;
        
        var $tpl_result;
        
        function __construct() {
            $this->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(); 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 嫩江县| 股票| 铁岭市| 土默特右旗| 德阳市| 泰和县| 祥云县| 哈尔滨市| 界首市| 当阳市| 紫阳县| 临城县| 湖州市| 河津市| 彭阳县| 梁河县| 塘沽区| 中阳县| 岳阳县| 中超| 井冈山市| 共和县| 通化市| 英山县| 古田县| 株洲县| 惠水县| 阿图什市| 汶川县| 汉中市| 彭阳县| 醴陵市| 甘德县| 海阳市| 遵化市| 会理县| 西宁市| 邯郸县| 佛坪县| 东源县| 鹤山市|