ThinkPHP Request Parameters Guide
In ThinkPHP, you can use the Request object in the controller to access the parameters passed to the controller. Here is an example:
use think\Request;
class Index
{
public function index(Request $request)
{
// 获取GET参数
$get_param = $request->param('param_name');
// 获取POST参数
$post_param = $request->post('param_name');
// 获取所有参数
$all_params = $request->param();
// 获取指定参数并设置默认值
$param_with_default = $request->param('param_name', 'default_value');
// 判断参数是否存在
$param_exists = $request->has('param_name');
// 获取原始参数(不经过过滤)
$raw_param = $request->param('param_name', '', 'raw');
// 获取路由中的参数
$route_param = $request->route('param_name');
}
}
By using the above methods, it is easy to obtain the parameters passed to the controller and handle them accordingly.