解析错误:语法错误,意外的文件结束,期望elseif(T_ELSEIF)或其他(T_ELSE)或endif(T_ENDIF)

时间:2018-05-07 08:57:49

标签: laravel exception blade laravel-blade laravel-excel

您好亲爱的我想创建一个客户刀片,为用户提供导入和导出excel文件。 我的customers_blade.php看起来像这样;

@extends('layouts.app')

@section('content')
<div class="panel-heading">Import and Export Data Into Excel File</div>

<div class="panel-body">
    {!! Form::open(array('route'=>'customer.import','method'=>'POST','files'=>'true')) !!}
    <div class="row">
        <div class="col-xs-10 col-sm-10 col-md-10">
            @if(Session::has('success'))
                <div class="alert alert-success">
                    {{Session :: get('message')}}
                </div>
                @if(Session::has(warning))
                <div class="alert alert-warning">
                    {{Session::get('message')}}
                </div>
                @endif
                <div class="form-group">
                    {!! Form::label('sample_file','Select File to Import:',['class'=>'col-md-3']) !!}
                    <div class="col-md-9">
                        {!! Form::file('customers',array('class'=>'form-control')) !!}
                        {!! $error->first('products','<p class="alert alert-danger">:message</p') !!}
                    </div>
                </div>
        </div>
        <div class="col-xs-2 col-sm-2 col-md-2 text-center">
            {!! Form::submit('Upload',['class'=>'btn btn-success']) !!}
        </div>
    </div>
    {!! Form::close() !!}
</div>
@endsection

但是当我转到页面时会发生此错误。我怎么编辑它。你能帮我么?

解析错误:语法错误,意外结束文件,期待elseif(T_ELSEIF)或其他(T_ELSE)或endif(T_ENDIF)(查看:/ home / vagrant / code / excel / resources / views / customers。 blade.php)

2 个答案:

答案 0 :(得分:4)

如果您在刀片文件中发现,您会发现缺少@endif

                    @if(Session::has('success'))
                        <div class="alert alert-success">
                            {{Session :: get('message')}}
                        </div>
                    @endif

在上一节@if(Session::has('success'))中,这个If并没有在任何地方结束。

@extends('layouts.app')

@section('content')
<div class="panel-heading">Import and Export Data Into Excel File</div>

<div class="panel-body">
    {!! 

    Form::open(array('route'=>'customer.import','method'=>'POST','files'=>'true')) !!}
        <div class="row">
            <div class="col-xs-10 col-sm-10 col-md-10">
                @if(Session::has('success'))
                    <div class="alert alert-success">
                        {{Session :: get('message')}}
                    </div>
                @endif  
                    @if(Session::has(warning))
                    <div class="alert alert-warning">
                        {{Session::get('message')}}
                    </div>
                    @endif
                    <div class="form-group">
                        {!! Form::label('sample_file','Select File to Import:',['class'=>'col-md-3']) !!}
                        <div class="col-md-9">
                            {!! Form::file('customers',array('class'=>'form-control')) !!}
                            {!! $error->first('products','<p class="alert alert-danger">:message</p') !!}
                        </div>
                    </div>
            </div>
            <div class="col-xs-2 col-sm-2 col-md-2 text-center">
                {!! Form::submit('Upload',['class'=>'btn btn-success']) !!}
            </div>
        </div>
        {!! Form::close() !!}
    </div>
    @endsection

希望这有帮助

答案 1 :(得分:0)

我刚刚在文件末尾甚至 HTML 结束标记下方添加了以下代码行:

<html>
<!-- Your Code -->
</html>
<?php endif; ?>

或者你也可以试试这个:

<html>
<!-- Your Code -->
</html>
<?php } ?>