laravel 解析错误:语法错误,文件意外结束,需要 elseif (T_ELSEIF) 或 else (T_ELSE) 或 endif (T_ENDIF)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50210452/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Parse error: syntax error, unexpected end of file, expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF)
提问by Cugurel
Hello dear i want to create a customer blade which provides users to import and export excel file. My customers_blade.php looks like this;
你好,亲爱的,我想创建一个客户刀片,为用户提供导入和导出 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
But when i go to page this error occurs. How can i edit it. Can you please help me?
但是当我转到页面时会发生此错误。我该如何编辑它。你能帮我么?
Parse error: syntax error, unexpected end of file, expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) (View: /home/vagrant/code/excel/resources/views/customers.blade.php)
解析错误:语法错误,文件意外结束,期待elseif(T_ELSEIF)或else(T_ELSE)或endif(T_ENDIF)(查看:/home/vagrant/code/excel/resources/views/customers.blade.php)
回答by Adnan Mumtaz
If you notice in your blade file you will find that you are missing @endif
如果你在你的刀片文件中注意到你会发现你丢失了 @endif
@if(Session::has('success'))
<div class="alert alert-success">
{{Session :: get('message')}}
</div>
@endif
In the above section @if(Session::has('success'))
this If was not ending anywhere.
在上面的部分中, @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
Hope this helps
希望这可以帮助