zoukankan      html  css  js  c++  java
  • ThinPHP_5的请求和响应

      

    thinkphp的请求对象request
      所有请求的参数都可以通过request接收

     方法一:

      request();助手函数

     方法二:

      use think\Request;
      Request::instance();[Resquest是单利模式折,只能通过instence获取实例]

    方法三:

      直接注入到方法,给index方法传参,参数类型Request对象,起个名称,$request[推荐使用]
      use think\Request;
      public function index(Request $request)
      {
        dump($request);
      }


    响应对象Response

      // 默认输出类型【惯例配置】
      'default_return_type' => 'html',


      if(!in_array($type,['json','jsonp','xml'])){
        $type = 'json';
      }
      //动态配置默认输出类型
      Config::set('default_return_type',$type);

  • 相关阅读:
    PAT1007
    PAT1005
    PAT1002
    PAT1003
    PAT1016
    PAT 1018
    PAT1009
    pat 1037
    解决Git合并分支发生的冲突
    站和队列的基本使用
  • 原文地址:https://www.cnblogs.com/Caveolae/p/7118990.html
Copyright © 2011-2022 走看看