Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:
class Index
{
public function __construct(Request $request)
{
$this->request = $request;
}
public function index()
{
return $this->request->param('id');
return 'hello world';
}
}
操作方法注入
class Index
{
public function index(Request $request)
{
dump($request->param()) ;
}
}
静态调用
use think\facade\Request;
//静态调用
class Index
{
public function index(Request $request)
{
return Request::param('name');
}
}
//助手函数
class Index
{
public function index(Request $request)
{
dd(request()->param());
}
}
class Index
{
public function index(Request $request)
{
$name = 'admin';
return view('welcome',['name'=>$name]);
}
}