Home >PHP Framework >ThinkPHP >5 ways to get the parameters in the api request address in thinkphp6

5 ways to get the parameters in the api request address in thinkphp6

藏色散人
藏色散人forward
2020-06-19 13:30:034795browse

The following tutorial column of thinkphp framework will introduce to you 5 methods of obtaining parameters in the api request address in thinkphp6. I hope it will be helpful to friends in need!

5 ways to get the parameters in the api request address in thinkphp6

#First method

tp6 The difference from tp5 is that tp6 inherits the controller Baseconroller, so we can directly use the request method in Baseconroller.

        public function show(){
            dump($this->request->param("abc",2,'intval'));
            }

Parameter analysis


5 ways to get the parameters in the api request address in thinkphp6name Parameter name

default Default value

filter Convert the obtained parameters into integers

The second method

No need to inherit BaseContoller and pass in the Request object in the method


5 ways to get the parameters in the api request address in thinkphp6##The third and fourth method

5 ways to get the parameters in the api request address in thinkphp6The fifth way to use request in human face mode

5 ways to get the parameters in the api request address in thinkphp6Personally, I think the first method is new in tp6, so we might as well develop it in practice Use it during the process, because it may be more convenient to use it. For example, it is very simple to judge whether it is a get request or other requests


5 ways to get the parameters in the api request address in thinkphp6

##

The above is the detailed content of 5 ways to get the parameters in the api request address in thinkphp6. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete