php手动加载视图文件

  1. test.php:
    php手动加载视图文件
    <?php
    $title = "测试标题";
    $a = require 'test.html';
    $a = exec($a);
    echo $a;
  2. test.html:
    php手动加载视图文件
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title><?php echo $title;?></title>
    </head>
    <body>
    <?php for($i = 0;$i < 10;$i++):?>
        <p><?php echo $i;?></p>
    <?php endfor;?>
    </body>
    </html>
  3. 关于smarty模板:
    smarty是在类中进行操作的,通过正则把 test.html 中的变量找出来,然后赋值给smarty中的变量,间接的给模板赋值
    
    
    
     本文转自 Lee_吉 51CTO博客,原文链接:http://blog.51cto.com/12173069/2071735