使用未定义的常量布局 - 假定 'layouts'(这将在 PHP 的未来版本中引发错误)

Use of undefined constant layouts - assumed 'layouts' (this will throw an Error in a future version of PHP)

您好,我正在尝试创建一个名为 showrecord 的新视图,但它显示错误:

Use of undefined constant layouts - assumed 'layouts' (this will throw an Error in a future version of PHP)

视图结构:

控制器:

public function index()
{
    return view('showrecord');
}

路线:

Route::resource('showrecord','ShowrecordController');

如何解决这个问题?

因为我无法查看您的代码

所以你在扩展你的视野

@extends('layouts.app')

所以我的假设是你不见了

单引号

@extends(layouts.app)

我会给你报错

尝试添加单引号或双引号

也有可能您 copy/paste 代码使用了错误的单引号:

@include(‘layouts.includes.header’) <= here the apostrophe is used instead of quote

将替换为

@include('layouts.includes.header')

如果您遇到这样的问题,原因之一是当您在前端(视图)中声明变量时,您忘记了以正确的语法声明变量,例如我们 你这样声明 {{$user-description}} 然后错误地声明了错误的语法,因为正确的语法是 {{$user->description}} enter image description here