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中的變量,間接的給模板賦值
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章