php - Kohana 错误...尝试分配非对象的属性

标签 php kohana

所以我试图浏览 Kohana 的第 3 版指南,但在 hello world 创建 View 部分不断收到错误。

ErrorException [ Warning ]: Attempt to assign property of non-object
Line 8: $this->template->message = 'hello world';

我将 site.php 放在 application/views 文件夹中...这是错误的位置吗...?

代码....

public $template = 'site';

public function action_index()
{
        $this->template->message = 'hello world';
}

如果有人能阐明我做错了什么,我将非常感激......谢谢

最佳答案

糟糕,忘记扩展正确的 Controller 。

class Controller_Welcome extends Controller {

需要有

class Controller_Welcome extends Controller_Template {

关于php - Kohana 错误...尝试分配非对象的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1736722/

相关文章:

php - 解析 TWIG 中的变量内容

php - Kohana内存泄漏?

mysql - 按 3 个类别排序

php - 如何使用 Kohana 3 ORM 处理 Database_Exception

kohana - 如何在 Kohana 3 的 route 不重蹈覆辙?

php - 使用 concat 从单独的单词中取出第一个字母

PHP 区分 only-date 或 only-time 以及两者

php - MySQL-Docker:连接问题

php - Woocommerce:在 class-wc-product-variable.php 文件中为 foreach() 提供的参数无效

php - 阿拉伯字母如何(正确)存储在 mysql 中?或 乙