树枝:如何获取请求字符串? [英] twig: How to get request string?

查看:25
本文介绍了树枝:如何获取请求字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网址:http://myserver.com/mypage?vid=1234

我想在页面上输出 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') }}

但是您应该在控制器中获取此值,然后将其传递给 twig.

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

此答案基于您使用 Symfony 框架的假设

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

这篇关于树枝:如何获取请求字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆