htmlspecialchars() 期望参数 1 为字符串,数组给定 laravel
htmlspecialchars() expects parameter 1 to be string, array given laravel
我正在尝试根据搜索页面中的价格(从高到低和从低到高)缩短记录(旅游),并使用已提交更改事件的表单。下面是表单的代码:
{!!Form::open(['route' => 'short','method' => 'GET', 'role' => 'search','class'=>'select-filters'])!!}
<input type="hidden" name="country" value="{{$country}}">
<input type="hidden" name="category" value="{{$category}}">
<input type="hidden" name="days" value="{{$days}}">
<select name="sort_price" id="sort-price" onchange="this.form.submit()">
<option value="" selected="">Sort by price</option>
<option value="lower">Lowest price</option>
<option value="higher">Highest price</option>
</select>
{!! Form::close() !!}
并且我已经在同一页中初始化了值,但出现错误 htmlspecialchars() expects parameter 1 to be string, array given
:
@if(Request::only('country') != null)
{{$country = Request::only('country')}}
@else
{{ $country = null }}
@endif
@if(Request::only('category') != null)
{{$category = Request::only('category')}}
@else
{{ $category = null }}
@endif
@if(Request::only('days') != null)
{{$days = Request::only('days')}}
@else
{{ $days = null }}
@endif
Request::only()
中的值是从索引页中的搜索表单传递的。当我死去并倾倒时:
{{dd(Request::only('country','category','days'))}}
我把传入的值以数组形式抛出
如果我只传递一个参数,它会转储单个键值对:
{{dd(Request::only('country'))}}
或
{{dd(Request::only('category'))}}
或
{{dd(Request::only('days'))}}
only()
总是 returns 一个数组,所以要得到一个字符串,这样做:
{{ request('country') }}
而不是这个:
{{ Request::only('country') }}
我正在尝试根据搜索页面中的价格(从高到低和从低到高)缩短记录(旅游),并使用已提交更改事件的表单。下面是表单的代码:
{!!Form::open(['route' => 'short','method' => 'GET', 'role' => 'search','class'=>'select-filters'])!!}
<input type="hidden" name="country" value="{{$country}}">
<input type="hidden" name="category" value="{{$category}}">
<input type="hidden" name="days" value="{{$days}}">
<select name="sort_price" id="sort-price" onchange="this.form.submit()">
<option value="" selected="">Sort by price</option>
<option value="lower">Lowest price</option>
<option value="higher">Highest price</option>
</select>
{!! Form::close() !!}
并且我已经在同一页中初始化了值,但出现错误 htmlspecialchars() expects parameter 1 to be string, array given
:
@if(Request::only('country') != null)
{{$country = Request::only('country')}}
@else
{{ $country = null }}
@endif
@if(Request::only('category') != null)
{{$category = Request::only('category')}}
@else
{{ $category = null }}
@endif
@if(Request::only('days') != null)
{{$days = Request::only('days')}}
@else
{{ $days = null }}
@endif
Request::only()
中的值是从索引页中的搜索表单传递的。当我死去并倾倒时:
{{dd(Request::only('country','category','days'))}}
我把传入的值以数组形式抛出
{{dd(Request::only('country'))}}
或
{{dd(Request::only('category'))}}
或
{{dd(Request::only('days'))}}
only()
总是 returns 一个数组,所以要得到一个字符串,这样做:
{{ request('country') }}
而不是这个:
{{ Request::only('country') }}