NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
## 判断Request 判断是否是GET Request::instance()->isGet() 判断是否是POST Request::instance()->isPost() 语法: ~~~ if($request->isGet()) if($request->isPost()) ~~~ ## index.php里代码 ~~~ <?php namespace app\index\controller; use think\Request; class Index { public function index(Request $request) { if($request->isGet()){ return "hallowordGet".input("id"); }elseif($request->isPost()) dump($request->only('name')); } } ~~~ ## Route里的代码 ~~~ <?php use think\Route; Route::any('index/[:id]','index/index/index',['method'=>'get|post']); //get方法可以传递id参数也可也不传递 ~~~ ## Route::any('index/[:id]','index/index/index',['method'=>'get|post']); 可以接受post或者gat