【发布时间】:2015-08-18 08:15:46
【问题描述】:
这是我控制器中的代码:
class ArticlesController extends Controller {
public function index()
{
$articles = Article::all();
return view('articles.index',compact('articles'));
}
}
我的 App.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
<meta charset="UTF-8">
<meta name=description content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
<div class="container">
@yield('content')
</div>
@yield('footer')
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Bootstrap JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</body>
</html>
还有 index.blade.php
<?php
@extends('app')
@section('content')
<h1>Articles</h1>
@stop
这是我得到的错误:
FatalErrorException in 5f3efcdeb3d9812b22b5491d0cba9f22 line 3:
syntax error, unexpected 'extends' (T_EXTENDS)
请帮忙。
下面列出的解决方案。虽然这个问题很愚蠢,而且很容易解决——但通过谷歌搜索很难找到一个直接的答案。因此保留这个问题。
【问题讨论】:
-
5f3efcdeb3d9812b22b5491d0cba9f22 是您的视图,当您运行您的应用程序时,刀片视图将转换为一个示例 php 临时文件,其中包含您使用普通 php 语言的视图。临时视图存储在:
storage/framework/views/尝试打开5f3efcdeb3d9812b22b5491d0cba9f22文件,看看发生了什么 -
我有
<? @extends('layouts/default') ?>,我只需要删除<? ?> -
@VaelVictus 您需要删除“”。如果有“?>”,也将其删除。
-
我就是这么说的。