Fatal error: Using $this when not in object context in 解决方法

粗心造成的错误

$this 只存在于下面情况

$obj = new objectTest();

$obj->test();

这种方法调用时,class中可以使用$this调用类中函数。

假如:

objectTest::test();

这种方法调用时,是不存在$this的,可以用self::来调用类中函数。

相关文章:

  • 2022-12-23
  • 2022-03-06
  • 2021-12-30
  • 2022-01-22
  • 2021-10-14
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
猜你喜欢
  • 2021-06-23
  • 2022-12-23
  • 2021-11-19
  • 2021-07-24
  • 2021-11-06
  • 2022-12-23
  • 2022-01-12
相关资源
相似解决方案