php - tp5 get request parameters
女神的闺蜜爱上我
女神的闺蜜爱上我 2017-06-20 10:07:39
0
2
826

1. Problem: Following the tp5 quick start manual, running a piece of code and the result (resource type) in the book are different
2. Related code:

public function hello(Request $request){
        echo '请求参数';
        dump(input());
        echo 'name:' .$request->param('name');
        echo '资源类型:' .$request->type(). '<br/>';
}

The access path is:
tp5.com/index/index/hello/test/ddd.html?name=think
The results in the book: Resource type: html,
The result of my operation is : Resource type: xml,
What is the problem? ? ?

There is another problem. If you change the access path to tp5.com/index/index/hello/test/ddd.html/name/think
The request parameter results will also change.
The original path access results :
array(2) {
["name"] => string(5) "think"
["test"] => string(3) "ddd"
}
Later path results:
array(2) {
["test"] => string(8) "ddd.html"
["name"] => string(5) "think"
}
How do you understand the path writing of tp5.com/index/index/hello/test/ddd.html?name=think?

女神的闺蜜爱上我
女神的闺蜜爱上我

reply all(2)
过去多啦不再A梦

tp5.com/index/index/hello/test/ddd.html?name=think
This way of writing, ? is obtained directly through $_GET,
? The front is parsed by the framework through pathinfo.

tp5.com/index/index/hello/test/ddd.html/name/think
If there is no ? in this url, the effect will be the same as:
tp5.com/index/index/hello/test/ddd.html/name/think .html
is the same, which means that .html can be omitted.
In addition to the default modules, controllers and operations, the previous / is parsed by key/value.
So, test/ddd.html
is parsed into ["test"] => string(3) " ddd".

三叔

I don’t understand the question, but

如果把访问路径改成tp5.com/index/index/hello/test/ddd.html/name/think

This sentence is wrong, it should be

tp5.com/index/index/hello/test/ddd/name/think.html

The return result is the same

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!