php Laravel - 语法错误,文件意外结束
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16116212/
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
Laravel - syntax error, unexpected end of file
提问by Ivanka Todorova
I have a website which works fine on host, but I'm currently trying to install it on localhost.
我有一个在主机上运行良好的网站,但我目前正在尝试将它安装在本地主机上。
I've downloaded everything and configured to work on localhost - Database & URL.
我已经下载了所有内容并配置为在 localhost - 数据库和 URL 上工作。
The problem is this error:
问题是这个错误:
Unhandled Exception
Message:
syntax error, unexpected end of file Location:
C:\Program Files (x86)\EasyPHP-12.1\www\laravel\view.php(386) : eval()'d code on line 118
未处理的异常
信息:
语法错误,文件意外结束位置:
C:\Program Files (x86)\EasyPHP-12.1\www\laravel\view.php(386) :第 118 行的 eval() 代码
And I don't know what causes it. Any solutions?
我不知道是什么原因造成的。任何解决方案?
P.S. I've setup in my windows' host file 127.0.0.1 myproject.dev
.
PS 我已经在我的 Windows 主机文件中进行了设置127.0.0.1 myproject.dev
。
回答by Jason Lewis
There is an error within one of your views. If there is a more detailed stack trace it should show you details of a view, although the name will be an md5()
string so it's a bit hard to find. You might want to delete all compiled Blade views in storage/views
and let Blade re-compile the views.
您的观点之一存在错误。如果有更详细的堆栈跟踪,它应该向您显示视图的详细信息,尽管名称将是一个md5()
字符串,因此很难找到。您可能希望删除所有已编译的 Blade 视图,storage/views
并让 Blade 重新编译这些视图。
If you still get the error then check your views to make sure you have all the proper closing tags, e.g., @endif
or @endforeach
如果您仍然收到错误,请检查您的视图以确保您拥有所有正确的结束标签,例如,@endif
或@endforeach
Always double check your views for any syntax errors.
始终仔细检查您的视图是否有任何语法错误。
回答by Benjamin Kohl
I've run into this same error and I was able to fix it by adding spaces to the content within an inline if statement. For example:
我遇到了同样的错误,我能够通过在内联 if 语句中向内容添加空格来修复它。例如:
Experienced error with:
遇到错误:
@if( BLAH )Output@endif
Fixed error with:
固定错误:
@if( BLAH ) Output @endif
This may not be a problem in all cases and it was certainly difficult to track down but it is just one example that can cause this exact error.
这可能不是所有情况下的问题,而且肯定很难追踪,但这只是一个可能导致此确切错误的示例。
回答by Phil McCarty
A variation of this problem -- I had a php block, which I'd opened with
<?
as opposed to <?php
worked fine on LocalHost/MAMP, but gave the above error under Nginx/Ubuntu 16.04/PHP7 (both Laravel)
这个问题的一个变体——我有一个 php 块,我打开它
<?
而不是<?php
在 LocalHost/MAMP 上运行良好,但在 Nginx/Ubuntu 16.04/PHP7(两个 Laravel)下给出了上述错误
回答by Farshid
you should remove a character from view file. for example my character was "," (a comma) before some "@endfor". when i remove those worked!
您应该从视图文件中删除一个字符。例如,我的字符是“,”(逗号),然后是“@endfor”。当我删除那些工作!