Strict Standards: Non-static method StreamComment::getCommentsHTML() should not be called statically, assuming $this from incompatible context(严格标准:非静态方法 StreamComment::getCommentsHTML() 不应静态调用,假设 $this 来自不兼容的上下文)
问题描述
我正在使用 Offiria(基于 joomla 的社交网络脚本),当我单击显示所有评论"链接以查看链接下的所有已发布评论时,我在第一条评论正上方收到以下错误.该函数可以工作,因此所有评论都展开,我可以看到所有评论,但错误也出现在那里.
I am using Offiria (joomla based social networking script) and when I click on the link "Show All Comments" to see all posted comments under a link, I get the following error right above the first comments. The function works so all comments expand and I can see them all but the error sits there as well.
严格标准:非静态方法StreamComment::getCommentsHTML()不应静态调用,假设 $this 来自不兼容C:Program 中的上下文FilesAmppswwwoffiriacomponentscom_streamcontrollerscomment.php第 31 行
Strict Standards: Non-static method StreamComment::getCommentsHTML() should not be called statically, assuming $this from incompatible context in C:Program FilesAmppswwwoffiriacomponentscom_streamcontrollerscomment.php on line 31
这是comment.php文件中的第31行:
Here is the line 31 in comment.php file:
我已尝试禁用 php.ini 中的所有错误报告选项,但错误不断出现.我也尝试将上述代码更改为public static function showall()",但我收到一个错误消息:严格标准:不应静态调用非静态方法 StreamComment::getCommentsHTML().
I have tried disabling all error reporting options in my php.ini but the error keeps coming up. I have also tried changing the above code to "public static function showall()" but I get an error that Strict Standards: Non-static method StreamComment::getCommentsHTML() should not be called statically.
如果您对此有任何帮助,我将不胜感激.
I would appreciate any help with this in advance.
这里是完整的comment.php
推荐答案
这里发生的事情是这个函数被静态调用了:
What's happened here is that this function has been called statically:
但它被定义为非静态方法,这意味着 PHP 期望它像这样被调用:
But it's defined as a non-static method, which means PHP is expecting it to be called like this:
如果这是唯一调用此方法的地方,或者它一直被静态调用,您可以通过将方法重新定义为静态来解决此问题:
If this is the only place this method is called, or it's consistently called statically, you can fix this by redefining the method as static:
希望这有帮助:) x
这篇关于严格标准:非静态方法 StreamComment::getCommentsHTML() 不应静态调用,假设 $this 来自不兼容的上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!