简体   繁体   中英

twig: How to get request string?

I have a url: http://myserver.com/mypage?vid=1234

I want to output 1234 on to the page. I have tried this but it is not working:

{{ app.request.get('vid') }}

what am I doing wrong or missing?

You can do this by using the "query" object :

{{ app.request.query.get('vid') }}

But you should get this value in the controller and then pass it to twig.

EDIT : This answer is based on the asumption that you are using Symfony Framework

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM