Home  >  Q&A  >  body text

php - tp5 get request parameters

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?

女神的闺蜜爱上我女神的闺蜜爱上我2653 days ago827

reply all(2)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-06-20 10:09:39

    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".

    reply
    0
  • 三叔

    三叔2017-06-20 10:09:39

    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

    reply
    0
  • Cancelreply