变量输出、赋值和替换

<?php

  namespace app\index\controller;

  use think\Controller;
  use think\View;

  class Index extends Controller
  {
    public function index()
    {
      //四种方法向页面赋值
      $this->assign('key','value');
      $this->view->key2 = 'value2';

        View::share('key3','value3'); //【先usethink\View】

      return $this->fetch('index',['email'=>'12356@qq.com']);
    }
  }

模板替换

  public function index()
  {
    return $this->fetch('index',['email'=>'12356@qq.com'],['STATIC' => 'Hello word']);
  }

__URL__
__STATIC__ /static [public/static]
__JS__ /static/js
__CSS__ /static/css

 

posted @ 2017-07-05 00:50  高锴  阅读(284)  评论(0编辑  收藏  举报