流明:在“刀片"视图中获取URL参数 [英] Lumen: get URL parameter in a Blade view

查看:48
本文介绍了流明:在“刀片"视图中获取URL参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从视图文件中获取url参数.

I'm trying to get a url parameter from a view file.

我有这个网址:

http://locahost:8000/example?a=10

和一个名为example.blade.php view 文件.

从控制器中,我可以使用$request->input('a')来获取参数a.

From the controller I can get the parameter a with $request->input('a').

是否有一种方法可以从视图中获取此类参数(而不必将其从控制器传递给视图)?

Is there a way to get such parameter from the view (without having to pass it from the controller to the view)?

推荐答案

效果很好:

{{ app('request')->input('a') }}

其中a是url参数.

在此处查看更多信息: http: //blog.netgloo.com/2015/07/17/lumen-getting-current-url-parameter-within-a-blade-view/

See more here: http://blog.netgloo.com/2015/07/17/lumen-getting-current-url-parameter-within-a-blade-view/

这篇关于流明:在“刀片"视图中获取URL参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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