php laravel 5.2 刀片模板无法解析

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39092712/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 01:48:36  来源:igfitidea点击:

laravel 5.2 blade template failing to parse

phplaravel-5.2bladelaravel-blade

提问by user101289

I have an issue with a laravel 5.2 site I'm working on. I have a master (main) layout that I'm using to set the main elements of the page up, and it's being used in the welcome page (that extends it) with no problem.

我正在处理的 laravel 5.2 站点有问题。我有一个主 ( main) 布局,我用它来设置页面的主要元素,并且在欢迎页面(扩展它)中使用它没有问题。

However, in some of the subpages I keep getting an error from the compiled view:

但是,在某些子页面中,我不断从编译视图中收到错误消息:

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

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

The error is Parse error: syntax error, unexpected '__data' (T_STRING), expecting ',' or ')'

错误是 Parse error: syntax error, unexpected '__data' (T_STRING), expecting ',' or ')'

There's literally nothing in my view except the title and the main content element, where I'm trying to dump a variable. The error is coming from Laravel, not my code (as far as I can tell).

在我看来,除了标题和主要内容元素之外,几乎没有任何内容,我试图在其中转储一个变量。错误来自 Laravel,而不是我的代码(据我所知)。

This is the whole view:

这是整个视图:

@extends('layouts.main)

@section('title', 'another page!')

@section('content')
{{dd($myvar)}}
@endsection

Any ideas why this is happening?

任何想法为什么会发生这种情况?

回答by Ravi Shankar

Please check the first line:

请检查第一行:

@extends('layouts.main)

The closing single quote (') is missing. It should be:

'缺少结束单引号 ( )。它应该是:

@extends('layouts.main')

回答by Ashok Chhetri

Use this as your first line:

将此作为您的第一行:

@extends('layouts.main')

We often forget to put 'on last word. Happens!

我们经常忘记说'最后一句话。发生!