Simply mimic the function of a smarty

? < PHP 
 class Mini {
     // template file directory 
    public $ template_dir = '' ;
     // file compiled template directory 
    public $ compile_dir = '' ;
     // define an array of receiving the external variable 
    public $ tpl_var = Array ();
     public function ASSIGN (Key $, $ value) { 
        $ the this -> tpl_var [Key $] = $ value;
         // var_dump ($ this-> tpl_var);
         // Die; 
    }
     public function the display ($ Template) { 
        $ CoMP = $ the this ->the compile ($ Template); 
        the include $ CoMP; 
    } 
    // compiling 
    public function the compile ($ Template) {
         // read the contents of 
        $ Source = file_get_contents ($ the this -> template_dir. ' / ' $ Template.);
         // Replace Label 
        Source str_replace = $ ( ' {$ ' , ' <? PHP echo $ this-> tpl_var [\' ' , $ Source); 
        $ Source = str_replace ( ' } ' , ' \ '];?> ' , $ Source) ;
         // echo $ Source;
        CoMP = $ $ the this .. -> Template compile_dir $ ' .php ' ; // 
        // var_dump ($ CoMP);
         // store content 
        file_put_contents (CoMP $, $ Source); // the file contents into 
        return $ CoMP ; 
    } 
}

 

Guess you like

Origin www.cnblogs.com/webcyh/p/11318492.html