<?php
namespace app\controller;
use think\Controller;
use think\facade\View;
class ThinkView extends Controller
{
public function index(){
View::share(['myson'=>'hank']);
//视图赋值
// $this -> assign('name','thinkphp');
// $this->assign('email','test@email.com');
// return $this->fetch();
//数组方式
// $this->assign([
// 'name'=>'thinkphp',
// 'email'=>'thinkphp@qq.com'
// ]);
// return $this->fetch();
// //直接fetch也可以传值
// return $this->fetch('index',[
// 'name'=>'this is fetch',
// 'email'=>'thinkphp@qq.com'
// ]);
$this->assign([
'name'=>'thinkphp',
'email'=>'thinkphp@qq.com'
]);
//过滤器
return $this->filter(function ($content)
{
return str_replace('think','zcv',$content);
})->fetch();
}
}
24_THINKPHP视图相关方法
最新推荐文章于 2021-03-09 22:36:35 发布