<?php
//index/controller/Demo1.php
namespace app\index\controller;use think\Controller;
use think\facade\View;
class Demo1 extends Controller
{
public function index()
{
//直接输出内容到页面,不通过模板
$content = '<h3>微语录www.top789.cn</h3>';
// return $this->display($content);
return $this->view->display($content);//推荐
// return View::display($content);
}
//使用视图输出
public function test()
{
//1、普通变量
$this->view->assign('name','Sam');
$this->view->assign('age','99');
//批量
$this->view->assign(['sex'=>'男','salary'=>'9999']);
//2、数组
$this->view->assign('arr',[
'id'=>'1',
'name'=>'SamC',
'sex'=>