TP5.1: request request object (obtained in four ways)

  Prepare:

  Create a file named requests.php under index/controller (note: don't name it request, because it is a keyword and is not allowed to be named )

  The difference between dynamic and static methods:

  Static method: public   static  function test(){}

  Dynamic method: ;public function test(){}

  It can be seen that the difference between them is that one is a static method and the other is an ordinary method.

  Dynamic method usage request

    

     Access via url: localhost/tp5 framework directory/thinkpublic//index.php/index/requests/request?name='small hamster'&age=18

  

 

   Use through static proxy

  

 

  Output result:

  

 

 

 

  Using requests via dependency injection

  

 

  result:

 

  Use the properties encapsulated in the Controller class

 

    

    result:

 

  above

  END

 

 

  

 

 

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325117391&siteId=291194637