0

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</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?

1
  • this is the code of a function or a class? is a static method? Commented Sep 28, 2011 at 22:42

1 Answer 1

1

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"));
1
  • That's really hard to read and should probably go in your question. Commented Sep 28, 2011 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.