donglanying3855 2015-10-04 00:38
浏览 97

使用Symfony HttpFoundation组件获取“GET”参数

I've started using SymfonyHttpFoundation Component in my projects ( not otherwise on Symfony) and have troubles retrieving GET values.

The relevant code is:

$Request=Symfony\Component\HttpFoundation\Request::createFromGlobals();
\Dev\Debug::dump($Request->query->get('action'));

This gets me a NULL ( \Dev\Debug::dump() is just a formatted wrapper for print_r)

The requested URL is:

http://[domainName]/compile.php?action=assets

The weird thing is 'though ( or maybe I am missing the point of the component) that is I create the Request ($Request=Symfony\Component\HttpFoundation\Request::createFromGlobals()), the requested URL doesn't show the get string anymore, it becomes:

http://[domainName]/compile.php

My question is - why is it returning a NULL value and why the GET parameters are removed from the URL?

  • 写回答

1条回答 默认 最新

  • dongzhaiqiang6108 2015-10-04 01:24
    关注

    Sorry, guys, problem solved. Went mad and this line escaped my sight:

    header('location:http://'.$_SERVER['HTTP_HOST'].'/compile.php');
    

    Obviously it was simply redirecting, without me noticing. And I simply jumped to conclusions that the new thing should be at fault.

    Http Component working fine.

    评论

报告相同问题?