如何修复我的 edit.blade.php 上的“语法错误,文件意外结束”?

我正在尝试使用 xampp 将编辑页面添加到我的 laravel 网站,但是当我尝试运行该链接时,它显示“语法错误,文件意外结束”。这是我得到的错误:


<?php echo $__env->make('master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\webLaravel\resources\views/edit.blade.php ENDPATH**/ ?>

参数“语法错误,文件意外结束”


我已经尝试在 PostController.php 上更改我的编辑功能


public function edit($id)

{

    $post = DB::table('posts')->where('id_kategori',$id)->get();

    return view('edit',['posts'=>$post]);

}

这是我的 index.blade.php 上的按钮


 <td><a href="/post/edit/{{ $post->id_kategori }}"><button type="button" 

class="btn btn-edit stn-md">Edit </button></td>

这是我在 web.php 中创建的路由


Route::get('/post/edit/{id}','PostController@edit');


皈依舞
浏览 121回答 2
2回答

慕后森

因为,您正在使用 获取数据get(),所以我假设您正在使用@foreach循环遍历表中的数据。您需要确保@foreach使用@endforeach刀片指令关闭循环来关闭循环。另外,请确保您正在关闭所有@ifwith@endif指令。@foreach....@endforeach

慕标5832272

从您的代码示例看来,您缺少结束 A 标记!您也不需要使用按钮和 A 标签。试试这个...&nbsp;<td>&nbsp; &nbsp; &nbsp; <a class="btn btn-edit stn-md" href="/post/edit/{{ $post->id_kategori }}"> Edit </a>&nbsp;</td>
打开App,查看更多内容
随时随地看视频慕课网APP