如何在blade.php中获取输入值 [英] How to get value of input in blade.php

查看:51
本文介绍了如何在blade.php中获取输入值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在下面使用输入值,该怎么做?我试着喜欢这个,但错误提示

I need to get a value of input to use below, how to do that? I tried to like this but error says

未定义的变量:名称

Undefined variable: name

<div class="col-md-10 col-md-offset-1">
      <input id="name" type="text" name="name" />
</div>


<div class="col-md-10 col-md-offset-1">
    @php
       $nameValue=$_GET['name'];
    @endphp
    <input id="name2" type="text" name="name2" value="{{$nameValue}}" />
</div>

推荐答案

$nameValue=Request::input('name')

从刀片模板中,您可以使用 Request 外观访问请求参数,也可以直接打印它:

From the blade template you can access the request parameters with the Request facade, you can also print it directly:

{{Request::input('name')}}

在最新版本中,您还可以使用:

In latest versions you can also use:

{{request()->input('name')}}

这篇关于如何在blade.php中获取输入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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