Laravel 拉维公司;叶片模板@section错误

Laravel 拉维公司;叶片模板@section错误,laravel,blade,lumen,templating,Laravel,Blade,Lumen,Templating,我想将全名显示为标题: @section('title', ['title' => $userdetail->fullName]) 我使用了上面的代码,它显示了字符串到对象转换的错误异常。将@section修改为此 @section('title', {{$userdetail->fullName}}) 像这样做-- 将第二个参数用双引号括起来,因为它会自动渲染变量和普通文本,而单引号只渲染文本而不渲染变量 记住,不能在刀片语法中使用刀片echo{{}。 比如-@sect

我想将全名显示为标题:

@section('title',  ['title' => $userdetail->fullName])

我使用了上面的代码,它显示了字符串到对象转换的错误异常。

将@section修改为此

@section('title', {{$userdetail->fullName}})
像这样做--

将第二个参数用双引号括起来,因为它会自动渲染变量和普通文本,而单引号只渲染文本而不渲染变量

记住,不能在刀片语法中使用刀片echo
{{}
比如-
@section('title',{{$userdetail->fullName}})

您不需要将其指定为关联数组,只需将变量和section指定为该变量的值即可

@section('title', "$userdetail->fullName")
@section('title', $userdetail->fullName)