小编dar*_*aez的帖子

Laravel 7 组件中未定义的变量

我有一个奇怪的问题,我正在为要在组件中显示的 Laravel 7 组件设置一个变量。虽然它在我的开发环境(MacOS 上的 MAMP)中工作,但当我将其加载到 HostGator 中的共享主机时,它不起作用。在 HostGator 中,它会抛出 500 错误,抱怨“未定义变量:page_title”。

关于这里可能发生什么有什么想法吗?

应用程序/组件/布局/ContentHeader.php

class ContentHeader extends Component
{
    public $page_title;
    public $breadcrumbs = [];

    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->page_title = 'Some title';
        $crumb = new \stdClass();
        $crumb->label = 'Home';
        $crumb->active = false;
        $this->breadcrumbs[] = $crumb;

        $crumb = new \stdClass();
        $crumb->label = $this->page_title;
        $crumb->active = true;
        $this->breadcrumbs[] = $crumb;
    }

    /**
     * Get the view / contents that …
Run Code Online (Sandbox Code Playgroud)

php components laravel laravel-7

3
推荐指数
1
解决办法
7043
查看次数

标签 统计

components ×1

laravel ×1

laravel-7 ×1

php ×1