准备:

  在index/controller下创建一个名为requests.php的文件(注意:不要起名为request,因为它是关键字,不被允许起名

  动态方法和静态方法的区别:

  静态方法:public  static  function  test(){}

  动态方法:;public  function  test(){}

  可以看出,他们的区别就是一个是静态方法,一个是普通方法。

  动态方法使用请求

TP5.1:request请求对象(使用四种方式获取)

    

     通过url访问:localhost/tp5的框架目录/thinkpublic//index.php/index/requests/request?name='小仓鼠'&age=18

  TP5.1:request请求对象(使用四种方式获取)

 

   通过静态代理使用

  TP5.1:request请求对象(使用四种方式获取)

 

  输出结果:

  TP5.1:request请求对象(使用四种方式获取)

 

 

 

  通过依赖注入使用请求

  TP5.1:request请求对象(使用四种方式获取)

 

  结果:

TP5.1:request请求对象(使用四种方式获取)

 

  通过Controller类中封装好的属性进行使用

TP5.1:request请求对象(使用四种方式获取)

 

    

    结果:

TP5.1:request请求对象(使用四种方式获取)

 

  以上

  END

 

 

  

 

 

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-16
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
相关资源
相似解决方案