/** * 注册一个shutdown函数(一般是清理函数) * @param callback $callback array(obj,func), 'class::staticfunc',.... * @param string $funcDesc function desc */ public static function registerShutdown($callback, $funcDesc) { if ($callback === null) { foreach (self::$funcShutdown as $funcDesc => $func) { try { if (is_array($func) || is_string($func)) { call_user_func($func); } else { $func(); } } catch (\ErrorException $e) { error_log('error shutdown:' . $funcDesc . " " . $e->getMessage() . "\n" . $e->getTraceAsString()); } } if (class_exists("\\Sooh\\DB\\Broker", false)) { \Sooh\DB\Broker::free(); } } else { self::$funcShutdown[$funcDesc] = $callback; } }