thinkPHP5 引入模板


有三種方法:
第一種: 直接使用 return view(); 助手函數
第二種: use think\View; class Admin extends View 見下
第三種: use think\Controller; class Admin extends Controller return $this->>fetch();
<?php
namespace app\admin\controller;
use think\View; //第二種
//use think\Controller; //第三種
class Admin extends View
{
public function lst()
{
//第一種方法載入模板 使用助手函數 在config里配置模板后綴 最簡單
//return view();
//第二種方法載入模板,需指定后綴格式 config配置無效 use think\View extends View
$view=new View(['view_suffix' => 'htm',]);
return $view->fetch();
//第三種 use think\Controller ; 在config里配置模板后綴 extends Controller
//return $this->>fetch();
}
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM