莫问 发表于 2018-12-15 16:03:03

PHP 自定义 Smarty 模板引擎类 高洛峰 细说PHP

  smarty模板引擎类简单工作原理
  利用Smarty 模板引擎类对模板文件中的变量进行编译,编译过程其实就是利用正则表达式翻译成PHP文件。例如 模板文件中{$title} 利用正则表达式找到并替换成
  自定义 Smarty 模板引擎类 smarty.class.php页面


                        $rep = "";
                        $newhtml = preg_replace($reg, $rep, $html);   
                        file_put_contents($comfile, $newhtml);
                        }
                        include $comfile;
            }
      }  调用模板页面 index.php
页: [1]
查看完整版本: PHP 自定义 Smarty 模板引擎类 高洛峰 细说PHP