摘要:<?phpnamespace app\index\controller;//use think\facade\View;use think\Controller;class Index extends Controller{ public function index() {  
<?php
namespace app\index\controller;
//use think\facade\View;
use think\Controller;
class Index extends Controller
{
public function index()
{
return '<h3>欢迎来学习php框架';
// return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:) </h1><p> ThinkPHP V5.1<br/><span style="font-size:30px">12载初心不改(2006-2018) - 你值得信赖的PHP框架</span></p></div><script type="text/javascript" src="https://tajs.qq.com/stats?sId=64890268" charset="UTF-8"></script><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="eab4b9f840753f8e7"></think>';
}
public function demo1()
{
$name='yanwu124567';
//return $name;
//使用视图类渲染
//return View::display('我的姓名是:<span style="color: #0000FF">'.$name.'</span>');
// return View::fetch('index@index/demo1',['name'=>$name]);
// return $this->fetch('index@index/demo1',['name'=>$name]);
// return $this->fetch('demo1',['name'=>$name]);
//$this->assign('name',$name);
// return $this->fetch();
return view('demo1',['name'=>$name]);
}
public function demo2()
{
//模版
$name='杨六';
$this->assign('name',$name);
$this->view->salary=600;
return $this->view->fetch();
}
public function demo3()
{
$this->view->name='杨世安';
$this->view->salary=7000;
return $this->view->fetch();
}
public function demo4()
{
//加载模板
$this->view->engine->layout(true);
return $this->view->fetch();
}
//模板继承
public function demo5()
{
return $this->view->fetch();
}
}
批改老师:天蓬老师批改时间:2019-01-17 09:02:49
老师总结:下次把注释代码删除再提交, 否则看起来真心累, 看了半天, 才发现你注释掉了,又没有高亮提示