douzhuo6931 2015-06-03 22:07
浏览 129
已采纳

Laravel 5语法错误,意外'扩展'(T_EXTENDS)

This is the code in my controller:

class ArticlesController extends Controller {
    public function index()
    {
        $articles = Article::all();
        return view('articles.index',compact('articles'));
    }

}

My 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>

And index.blade.php

<?php

@extends('app')

@section('content')
    <h1>Articles</h1>
@stop

This is the error that I get:

FatalErrorException in 5f3efcdeb3d9812b22b5491d0cba9f22 line 3:
syntax error, unexpected 'extends' (T_EXTENDS)

Please help.


Solution listed below. While the issue is silly, and easy to fix - it's hard to find a straight answer via Google Search. Hence keeping this question.

  • 写回答

4条回答 默认 最新

  • douvcpx6526 2015-06-03 22:11
    关注

    The <?php ?> Tags are not required in .blade.php files. Remove them and it works.

    (The blade syntax need not be in php tags. You can however, include PHP code in tags.)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀