解析错误:语法错误,意外的文件结束----对于我的提交页面

时间:2018-01-06 06:40:42

标签: php laravel laragon

我在这一行收到错误

<?php echo $__env->make('layout.app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

提交页面时的错误如下:

  

“解析错误:语法错误,意外结束文件(查看:C:\ laragon \ www \ todolist \ resources \ views \ todo \ home.blade.php)”

请帮忙

另外我的home.blade.php有这个

@extends('layout.app')
@section('body')
    <br>
    <a href="todo/create" class="btn btn-info">Add New</a>
    <div class="col-lg-4 col-lg-offset-4">
        <center><h1>Todo Lists</h1></center>
        <ul class="list-group">
            @foreach($todos as $todo)
            <li class="list-group-item">
            {{$todo->body}}
            </li>
        </ul>
    </div>

3 个答案:

答案 0 :(得分:2)

您需要将@endsection添加到刀片文件的末尾:

@extends('layout.app')
@section('body')
    <br>
    <a href="todo/create" class="btn btn-info">Add New</a>
    <div class="col-lg-4 col-lg-offset-4">
        <center><h1>Todo Lists</h1></center>
        <ul class="list-group">
            @foreach($todos as $todo)
            <li class="list-group-item">
            {{$todo->body}}
            </li>
        </ul>
    </div>
@endsection

答案 1 :(得分:1)

关闭li标签后应该有一个“@endforeach”:

@extends('layout.app')
@section('body')
    <br>
    <a href="todo/create" class="btn btn-info">Add New</a>
    <div class="col-lg-4 col-lg-offset-4">
        <center><h1>Todo Lists</h1></center>
        <ul class="list-group">
            @foreach($todos as $todo)
            <li class="list-group-item">
            {{$todo->body}}
            </li>
            @endforeach
        </ul>
    </div>
@endsection

答案 2 :(得分:0)

有时,当您使用<?php your code ?><? your code ?>而不是@php your code @endphp时,会得到相同的错误

通常,如果您忘记关闭@enif @endforeach @endsection等,则会发生这种情况...