常见的变量输出有如下情况: 1.在控制器中按如下方式赋值 ~~~ $this->assign('hello','Hello ThinkCMF!'); return $this->fetch(); ~~~ 在模板中: ~~~ <div>{$hello}</div> ~~~ 2.在控制器中赋值数组变量 ~~~ $data = ['hello'=>'Hello ThinkCMF!','username'=>'老猫']; $this->assign('data',$data); return $this->fetch(); ~~~ 在模板中: ~~~ <div>{$data.hello}</div> <div>{$data.username}</div> ~~~ 3.在控制器中赋值对象变量 ~~~ $data = ['hello'=>'Hello ThinkCMF!','username'=>'老猫']; $data = json_decode(json_encode($data)); $this->assign('data',$data); return $this->fetch(); ~~~ 在模板中: ~~~ <div>{$data:hello}</div> <div>{$data:username}</div> ~~~ 或: ~~~ <div>{$data->hello}</div> <div>{$data->username}</div> ~~~