云梦编程网

当前位置:首页 > PHP教程 >

PHP Fatal error: Using $this when not in object context in

作者:佚名 时间:2023-11-23 09:04:37 阅读:(8)

今天在服务器上面执行了一个php脚本,提示:PHP Fatal error:  Using $this when not in object context in,接下来云梦编程就就为大家详细的介绍一下产生的原因及解决方法,有需要的小伙伴可以参考一下:

PHP Fatal error: Using $this when not in object context in

1、错误提示:

[root@localhost ~]# /usr/local/php/bin/php /data/crontabs/images.php
开始:2023-11-21 10:12:41
   PHP Fatal error:  Using $this when not in object context in /data/crontabs/images.php on line 53

2、错误原因:

在静态方法中使用$this或者直接调用非静态的方法。

3、解决方法:

(1)、在静态方法中使用self::来代替$this->

(2)、实例化类后再调用该方法


以上就是云梦编程为大家介绍的关于Using $this when not in object context in解决方法的全部内容了,了解更多相关文章请关注云梦编程网!

最新文章

热门文章