t h i s − > a s s i g n ( ) 将 后 台 数 据 传 递 到 前 台 页 面 中 t p 5.1 以 前 this->assign()将后台数据传递到前台页面中 tp5.1以前 this−>assign()将后台数据传递到前台页面中tp5.1以前this->assign()用法
user think\Controller;
class Index extends Controller{
public function index(){
$this->assign('name',$data);
$this->fetch('index');
}
}
tp5.2之后$this->assgin()用法
use think\ViewController;
class Index extends ViewController{
public function index()
{
$this->assign(['name'=>$data]);
return $this->fetch('/index');
//或是使用助手函数 不需要继承ViewController
return view()->assign(['name'=>$data]);
}
{