Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php laravel刀片包括错误-语法错误,意外_Php_Laravel_Blade - Fatal编程技术网

Php laravel刀片包括错误-语法错误,意外

Php laravel刀片包括错误-语法错误,意外,php,laravel,blade,Php,Laravel,Blade,我在本地使用Laravel 4和EasyHP 14.1。 我创建了一条路线: Route::get('/test', function() { return View::make('test'); }); 布局(testlayout.blade.php): @产量(‘容器’) 和一个视图(test.blade.php): @extends(“testlayout”) @节(“容器”) 你好 @停止 它工作正常,我得到“你好!” 但是当一个用户通过添加一个include来更改我的布

我在本地使用Laravel 4和EasyHP 14.1。 我创建了一条路线:

Route::get('/test', function()
{
    return View::make('test');
});
布局(testlayout.blade.php):


@产量(‘容器’)
和一个视图(test.blade.php):

@extends(“testlayout”)
@节(“容器”)
你好
@停止
它工作正常,我得到“你好!”

但是当一个用户通过添加一个include来更改我的布局时,如下所示:

<!doctype html>
<html>
<head>
    <title></title>
</head>
<body>
    <div class="container">
        @yield('container')
    </div>
        @include('testfooter')
</body>
</html>

@产量(‘容器’)
@包括('testfooter')
使用我的页脚(testfooter.blade.php):

@节(“testfooter”)
2013-2014
@展示
我有一个错误“语法错误,意外的“/”

Laravel生成的代码(在app\storage\views中找到)错误:

<!doctype html>
<html>
<head>
    <title></title>
</head>
<body>
    <div class="container">
        <?php echo $__env->yieldContent('container')
    </div>
        <?php echo $__env->make('testfooter', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>; ?>
</body>
</html>

; ?>
拉威尔忘记了
;?>
yieldContent('container')
之后添加两个
;?>
之后。。。render()
。 我试过很多东西,但现在真的一点线索也没有

更新1 我已经重新安装了一个新的Laravel和guest什么,问题仍然是一样的。没有@include没关系,有了@include,我一次又一次地犯同样的错误

更新2并解决问题(感谢@majimboo)! 这简直令人难以置信所有这些故事都与代码无关。这是文本编辑器的问题:Windows上的记事本+。出于未知原因,并且仅针对某些文件,它从“编辑/EOL转换/windows格式”切换到“编辑/EOL转换/Mac格式”。显然,拉威尔根本不喜欢Mac格式!因此,如果您在Windows上使用记事本+,请确保您有:“下线转换/Windows格式”

您有:

@section("testfooter")
    <div class="footer">2013-2014</div>
@show // <--
@节(“testfooter”)
2013-2014

@show/问题出在要包含的文件中

首先要检查问题是否真的存在,请删除testfooter.blade.php中的所有内容,然后从浏览器中打开视图。您将注意到不再存在错误

将您的
testfooter.blade.php
更改为:

<div class="footer">2013-2014</div>
您可以将其包括为:

<!-- app/views/example.blade.php -->

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Narwhals</title>
</head>
<body>
    @include('header')
    <p>Why, the Narhwal surely bacons at midnight, my good sir!</p>
    @include('footer')
</body>
</html>

角鲸
@包括('标题')
啊,纳瓦尔人肯定会在午夜到来,我的好先生

@包括('页脚')
查看了解更多有关刀片的信息


问题似乎是其他的,我只想分享一下,如果它能帮助你:

我使用记事本++作为文本编辑器,出于某种奇怪的原因 决定使用“MAC格式”作为行尾(EOL)格式。 显然,刀片式框架无法应对这种情况。使用 转换功能(在记事本++:编辑->下线转换)用于转换 到Windows格式,它会工作得很好


通常情况下,拉威尔会给这个问题一个很好的提示。问题可能出在CSS或JS include语句中。首先,确保已打开laravel的调试模式。下面是如何做到这一点

  • 第16行的Config/app->debug=true
  • 刷新错误所在的页面
  • 我故意省略了css文件的结尾“)”。laravel FW显示了错误的位置,它将向您显示类似的错误


    希望它能有所帮助。

    在我的例子中,问题是某些PHP中的一个未终止字符串位于文件中与Laravel抱怨的完全不同的部分。我删除了文件中的所有内容,然后一行一行地重新添加,从而消除了它。

    Damn。我也看到了,但不确定我是否正确。嗨。我做了更改,删除了“app\storage\views”中的文件并重试,但不幸的是,相同的错误仍然存在。请同时清除浏览器缓存。要清楚,为什么仅为页脚设置第二个部分?由于
    @include()
    似乎在指定一个视图文件,尽管您似乎没有在其他任何地方引用该节(换句话说,请尝试从页脚文件中删除
    @section()
    附件(例如,保留html内容)),即使仅使用html,我也有相同的错误。:/,我已经投票通过了这个问题,希望它能吸引人们的注意力,因为我已经没有更多的想法了。谢谢。真奇怪。如果我删除@include,它会工作,如果我把它放回去,我也会有同样的错误。@Peter我补充了一个答案。请参阅以了解更多信息。搜索
    包含
    .Hi。谢谢你的回复。我只尝试了
    2013-2014
    ,在
    testfooter.blade.php
    中没有尝试,但问题仍然存在。我已经清除了浏览器缓存并删除了
    存储/视图中的文件
    @Peter Laravel现在生成了什么代码?它改变了吗?你的例子很有效。我已经添加了
    @yield('container')
    ,并将您的代码用作布局,并调用了
    @extends(“示例”)
    @section('container')
    您好
    @stop
    就可以了!难以置信!我真的不明白为什么前面的代码不起作用。@Peter我添加了一些脚注,可能会有所帮助。很抱歉,如果我不能再帮你了。@Peter,但如果它真的有帮助,我也会很感激你接受它作为一个回答:)你好。
    @section("testfooter")
        <div class="footer">2013-2014</div>
    @show // <--
    
    @section("testfooter")
        <div class="footer">2013-2014</div>
    @stop // <--
    
    <div class="footer">2013-2014</div>
    
    <!-- app/views/header.blade.php -->
    
    <h1>When does the Narwhal bacon?</h1>
    
    <!-- app/views/footer.blade.php -->
    
    <small>Information provided based on research as of 3rd May '13.</small>
    
    <!-- app/views/example.blade.php -->
    
    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Narwhals</title>
    </head>
    <body>
        @include('header')
        <p>Why, the Narhwal surely bacons at midnight, my good sir!</p>
        @include('footer')
    </body>
    </html>