<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 安裝smarty 通過composer安裝 ~~~bash composer require smarty/smarty ~~~ # 創建一個服務 ~~~go php think make:service SmartyService ~~~ SmartyService.php ~~~php <?php declare (strict_types=1); namespace app\service; class SmartyService extends \think\Service { protected $smarty; /** * 注冊服務 * * @return mixed */ public function register() { //初始化Smarty $this->smarty = new \Smarty(); // 綁定類實例 $this->app->bind('smarty', $this->smarty); } /** * 執行服務 ,配置Smarty * * @return mixed */ public function boot() { $this->smarty->caching = config('smarty.caching'); $this->smarty->cache_lifetime = config('smarty.cache_lifetime'); $this->smarty->setTemplateDir(config('smarty.template_dir')); $this->smarty->setCompileDir(config('smarty.compile_dir')); $this->smarty->cache_dir = config('smarty.cache_dir'); $this->smarty->config_dir = config('smarty.config_dir'); $this->smarty->setLeftDelimiter(config('smarty.left_delimiter')); $this->smarty->setRightDelimiter(config('smarty.right_delimiter')); $this->smarty->auto_literal = config('smarty.auto_literal'); } } ~~~ # 創建config配置文件 在config目錄下新建`smarty.php` ~~~php <?php // +---------------------------------------------------------------------- // | 模板設置 // +---------------------------------------------------------------------- return [ //是否緩存 'caching' => false, //緩存周期(開啟緩存生效) 'cache_lifetime' => 120, // 設置模板基礎路徑 'template_dir' => root_path('view'), // 模板編譯路徑 'compile_dir' => runtime_path('smarty/compile'), // 緩存目錄 'cache_dir' => runtime_path('smarty/cache'), // 配置目錄(比較雞肋,建議:使用框架的config就好了) 'config_dir' => config_path('smarty'), // 模板引擎左邊標記 'left_delimiter' => '<{', // 模板引擎右邊標記 'right_delimiter' => '}>', //空格策略 'auto_literal' => false, ]; ~~~ # 使用 在控制器中如下 ~~~lisp app('smarty')->display('index/index/index.tpl', compact('articles')); ~~~ ## 注意 * thinkphp6.0的特性不能在控制器中使用 exit ,die 等終止腳本的函數 * 如果自定義處理報錯中需要使用exit()將結果輸出,否則會重復渲染頁面。 # 公共數據賦值 可以創建一個`BaseController`控制器在構造函數中賦值 ~~~objectivec //一些公共的數據 app('smarty')->assign('index_info', session('index_info')); ~~~ 這樣就能在模板任意地方使用`<{$index_info->nickname}>`
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看