小编Fla*_*aco的帖子

使用register_shutdown_function()时,为什么我的'关闭回调'无效?

警告:register_shutdown_function():无效的关闭回调

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');
        } 
Run Code Online (Sandbox Code Playgroud)

}

我在我的主类中使用这个特性并从中调用函数

    use ErrorTrait;

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


    self::shutdown_function(); }
Run Code Online (Sandbox Code Playgroud)

然后在这一点上,我在一个名为"run"的函数中调用test中的函数

我所做的只是简单地调用函数.

      public function run()
        {
        self::test ();
          // Rest of code}
Run Code Online (Sandbox Code Playgroud)

关于为什么会导致问题的任何想法?

php compiler-errors shutdown traits

5
推荐指数
1
解决办法
2528
查看次数

标签 统计

compiler-errors ×1

php ×1

shutdown ×1

traits ×1