tp5.1创建模块
把build.php放在应用目录下面,
然后打开cmd,
cd../../
cd phpstudy/www/tp5
php think build
tp5.1控制器
return 输出写的东西
return 不能返回数组,必须返回json。
重定向就是直接跳转,$this->redirect('News/category',['cate_id'=>2]); success是有时间的跳转,error和success一样的。 头上加
use app\index\admin\User;
use think\Controller;
//默认错误跳转对应的模板文件
'dispatch_error_tmpl' => 'public/error',
//默认成功跳转对应的模板文件
'dispatch_success_tmpl' => 'public/success',
return view(); 和3.2的$this->display();是一样的。
config('app.app_name','emt')//后面加一个值是设置 不加是继承原样输出
//第二个
view()
fetch('index',[
])// 一样,第一个括号写方法,可以跨控制器,第二个数组里写参数前面必须加return;
//例子:
return $this->fetch('index', [
'name' => 'ThinkPHP',
'email' => 'thinkphp@qq.com'
]);
$this->redirect('News/category', ['cate_id' => 2]);
浙公网安备 33010602011771号