当前位置: 首页 > 后端技术 > PHP

thinkphprequest

时间:2023-03-29 20:29:37 PHP

request对象由thinkRequest负责只需要依赖注入request对象构造方法注入publicfunction__construct(Request$request){$this->request=$request;}请求信息//+----------------------------------------------------------------//+----------------------------------------------------------------------//|应用设置//+----------------------------------------------------------------------return[//在兼容模式下使用的PATHINFO变量名'var_pathinfo'=>'s',//与PATH_INFO兼容get'pathinfo_fetch'=>['ORIG_PATH_INFO','REDIRECT_PATH_INFO','REDIRECT_URL'],//pathinfodelimiter'pathinfo_depr'=>'/',//HTTPS代理标识符'https_agent_name'=>'',//URL伪静态后缀'url_html_suffix'=>'html',//自动生成的普通URL参数'url_common_param'=>true,//是否开启路由延迟解析'url_lazy_route'=>false,//是否强制使用路由'url_route_must'=>false,//合并路由规则'route_rule_merge'=>false,//路由是否完全匹配'route_complete_match'=>false,//使用注解路由'route_annotation'=>false,//是否开启路由缓存'route_check_cache'=>false,//路由缓存连接参数'route_cache_option'=>[],//路由缓存键'route_check_cache_key'=>'',//访问控制器层名称'controller_layer'=>'controller',//空控制器名称'empty_controller'=>'Error',//是否使用controllersuffix'controller_suffix'=>false,//默认路由变量规则'default_route_pattern'=>'[\w\.]+',//域名root,suchasthinkphp.cn'url_domain_root'=>'',//是否自动转换URL中的Controllers和actionsname'url_convert'=>true,//表单请求类型伪装变量'var_method'=>'_method',//表单ajax伪装变量'var_ajax'=>'_ajax',//表单pjax伪装变量'var_pjax'=>'_pjax',//是否开启请求缓存true自动缓存支持设置请求缓存规则'request_cache'=>false,//请求缓存有效期'request_cache_expire'=>null,//全局请求缓存排除规则'request_cache_except'=>[],//默认控制器名称'default_controller'=>'Index',//默认动作名称'default_action'=>'index',//动作方法后缀'action_suffix'=>'',//默认JSONP格式返回处理方法'default_jsonp_handler'=>'jsonpReturn',//默认JSONP处理方法'var_jsonp_handler'=>'callback',];连接如下http://localhost:8082/index.php/index/ming/name。此时的html访问相当于http://localhost:8082/index.php/index/ming/name参数绑定本次连接http://localhost:8082/index/ming/year/34/month/34定义路由','index/in敏捷');其中month是一个可选的控制器,如下所示响应*/publicfunctionindex($year,$month='01'){return$year.$月;}/***显示创建资源表单页面。**@return\think\Response*/publicfunctioncreate(){//}/***保存新创建的资源**@param\think\Request$request*@return\think\Response*/publicfunctionsave(Request$request){//}/***显示指定资源**@paramint$id*@return\think\Response*/publicfunctionread($id){//}/***显示编辑资源表单页面。**@paramint$id*@return\think\Response*/publicfunctionedit($id){//}/***保存更新的资源**@param\think\Request$request*@paramint$ID*@return\think\Response*/publicfunctionupdate(Request$request,$id){//}/***删除指定资源**@paramint$id*@return\think\Response*/publicfunctiondelete($id){//}publicfunction__call($name,$arguments){//TODO:实施__call()方法。返回“错误请求”;}}现在输入http://localhost:8082/index/ming/year/34/month/34返回3434requestcache将请求缓存