【问题标题】:parse error: syntax error, unexpected '<', expecting ')'解析错误:语法错误,意外 '<',期待 ')'
【发布时间】:2021-11-05 17:58:23
【问题描述】:

我尝试改变标题页的使用

@section('page_title', {{  $mapel->subjects_name  }} )

但查看错误信息

语法错误,意外'

在我的控制器中

public function show($id)
{
    $mapel = Subjects::findOrFail($id);
    return view('lesson.index', compact('mapel'));
}

我试过用 dd($mapel->subjects_name) 检查数据出来了,谢谢你

【问题讨论】:

  • 更改为@section('page_title', $mapel-&gt;subjects_name) 你不需要在blage 指令Documentation 中解析刀片语法

标签: laravel laravel-blade


【解决方案1】:

为什么需要compact,我觉得可以直接发送$mapel like

return view('lesson.index', $mapel);

然后在视图中

@section('page_title', $mapel->subjects_name );

@section('page_title', ['mapel_subject_name' => $mapel->subjects_name] )

随你喜欢。

【讨论】:

    猜你喜欢
    • 2016-01-29
    • 2013-06-28
    • 2011-09-22
    • 1970-01-01
    • 2019-05-16
    • 2012-07-04
    • 2013-09-22
    相关资源
    最近更新 更多