开发者

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

I've got problem:

I have a script that I'm working with and just upgraded to PHP 5.3.

In my kit_parser.php I'm getting the following fatal error:

Fatal error: Using $this when not in object context in /home/sitename/public_html/secure/includes/hooks/kits/kit_parser.php on line 71

This is the section of code it's referencing:

LINE 71---> $this->kit__log_add(array("<b>PHP Warning开发者_Python百科</b> [$errno] $errstr on line $errline in file $errfile"));

    function kit_error($errno, $errstr, $errfile, $errline, $die = false) {
    if (1==1){//$this->displayErrors ) {
        switch ($errno) {
            /* Custom Errors */
            case E_USER_ERROR:
            break;
            case E_USER_WARNING:
            break;
            case E_USER_NOTICE:
            break;
            case E_ERROR:
                $this->kit__log_add(array("<b>PHP Error</b> [$errno] $errstr on line $errline in file $errfile"));
                die();
            break;
            case E_WARNING:
                $this->kit__log_add(array("<b>PHP Warning</b> [$errno] $errstr on line $errline in file $errfile"));
            break;
        }
        return true;
    }
    return false;
}

Why is the error coming? Nothing found, never seen before in my other scripts. Can anyone help me please?


This error usually means that you're using $this in a static class method. Make sure that the method this code is in is not static. If it is, you should probably be using this syntax instead:

YourClassNameGoesHere::kit__log_add(array("<b>PHP Warning</b> [$errno] $errstr on line $errline in file $errfile"));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜