这是我 Controller 中的代码:
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)
请帮忙。
下面列出了解决方案。虽然这个问题很愚蠢,而且很容易解决,但很难通过 Google 搜索找到直接的答案。因此保留这个问题。
最佳答案
<?php ?>
.blade.php 文件中不需要标签。删除它们就可以了。
( Blade 语法不需要在 php 标签中。但是,您可以在标签中包含 PHP 代码。)
关于php - Laravel 5 语法错误,意外 'extends' (T_EXTENDS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30631635/