【问题标题】:Codeigniter - Cannot access property started with '\0' errorCodeigniter - 无法访问以“\0”错误开头的属性
【发布时间】:2019-10-04 16:45:58
【问题描述】:

我在 codeigniter 中调用函数表单库,它给了我以下错误

PHP 致命错误:无法访问第 85 行 /system/core/Exceptions.php 中以“\0”开头的属性

代码

$this->load->library('test_library');
TEST_LIBRARY::first();

类文件

class TEST_LIBRARY
{
    public function first(){
        return "here";
    }
}

但是,当我使用此方法$this->test_library->first(); 调用该函数时,它工作正常。

在不确定发生了什么之前,它是双向工作的。 error.log 文件中没有其他日志消息。如何进一步调试并解决此问题?

【问题讨论】:

    标签: php codeigniter codeigniter-3


    【解决方案1】:

    函数first 不是静态的,但您调用时就好像它是静态的一样。将 test_libaray.php 更改为:

    class TEST_LIBRARY {
       public function __construct() {}
    
       public function first() {
           return "here"; // i suggest to use __METHOD__ or __LINE__ instead
       }
    
    }
    

    然后试试:

    $test_library = new TEST_LIBRARY();
    $test_libaray->first();
    

    代替:

    TEST_LIBRARY::first();
    

    或者你可以改变first static。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-04
      • 1970-01-01
      • 2013-03-20
      • 1970-01-01
      • 2012-12-28
      • 2015-06-04
      • 2017-04-04
      相关资源
      最近更新 更多