首页 > 解决方案 > Laravel Compact 可变刀片文件显示语法错误

问题描述

这是我的控制器代码:

 public function method(Request $request){
   $typeType = $request->type; //this variable show 'Booking'

   return view('home.profile',compact('type'));
 }

这是刀片文件:

 @extends('layouts.dashboard')
 @section('page_heading',{{$taskType}})
 @section('section')
    //here some code
 @stop

如果我使用这个刀片代码。然后我遇到了这个问题:

解析错误:语法错误,意外的“<”(查看:resources/view/home/profile.blade.php)

如果我在刀片上使用此代码

 @extends('layouts.dashboard')
 @section('page_heading','{{$taskType}}')
 @section('section')
    //here some code
 @stop

然后刀片文件显示它:

<?php echo e($taskType); ?>

我想在刀片文件上显示它:

 Booking

我怎么解决这个问题?

标签: phplaravellaravel-5.4laravel-blade

解决方案


可能您不需要{{ }}刀片指令。

所以将其更改为:

 @section('page_heading', $taskType)

推荐阅读