5

Warning: register_shutdown_function(): Invalid shutdown callback

trait ErrorTrait {

        public function shutDownFunction() { 
            $error = error_get_last();
                // fatal error, E_ERROR === 1
                if ($error['type'] === E_ERROR) { 
                    //do your stuff     

                    $messageStore="Using $this when not in object context";

                    if (strstr ( $error['message'],$messageStore))

                    {
                        echo "found it";

                    }

                } 
                }




        public function shutdown_function()
        {
        register_shutdown_function('shutDownFunction');
        } 

}

I use this trait in my main class and call the functions from it

    use ErrorTrait;

     public function test()
{   self::shutDownFunction();


    self::shutdown_function(); }

And then at this point I call the function in test in a function called "run"

All I do is a simply call the function.

      public function run()
        {
        self::test ();
          // Rest of code}

Any ideas as to why this is causing problems?

1 Answer 1

8

You are passing a string instead of a callable into register_shutdown_function. The call should look like

register_shutdown_function([$this, 'shutDownFunction']);
Sign up to request clarification or add additional context in comments.

Comments

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.