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?
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
This sentence is wrong, it should be
The return result is the same