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

藏色散人
Release: 2020-06-19 13:32:56
forward
4802 people have browsed it

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'));
            }
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template