diff --git a/library/think/App.php b/library/think/App.php index 2436c027..d4e50072 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -99,7 +99,11 @@ class App break; case 'callable': // 执行回调方法 - $data = call_user_func_array(self::$dispatch['callable'], self::$dispatch['params']); + if (is_callable(self::$dispatch['callable'])) { + $data = call_user_func_array(self::$dispatch['callable'], self::$dispatch['params']); + } else { + throw new Exception('not callable : ' . (is_array(self::$dispatch['callable']) ? implode('->', self::$dispatch['callable']) : self::$dispatch['callable']), 10009); + } break; case 'closure': // 规则闭包 diff --git a/library/think/Route.php b/library/think/Route.php index 54489b09..093286d7 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -315,7 +315,7 @@ class Route case 'class': // 绑定到类 $array = explode('/', $url, 2); - if (isset($array[1])) { + if (!empty($array[1])) { self::parseUrlParams($array[1]); } $return = ['type' => 'callable', 'callable' => [self::$bind['class'], $array[0] ?: Config::get('default_action')], 'params' => []]; @@ -323,9 +323,9 @@ class Route case 'namespace': // 绑定到命名空间 $array = explode('/', $url, 3); - $class = isset($array[0]) ? $array[0] : Config::get('default_controller'); - $method = isset($array[1]) ? $array[1] : Config::get('default_action'); - if (isset($array[2])) { + $class = !empty($array[0]) ? $array[0] : Config::get('default_controller'); + $method = !empty($array[1]) ? $array[1] : Config::get('default_action'); + if (!empty($array[2])) { self::parseUrlParams($array[2]); } $return = ['type' => 'callable', 'callable' => [self::$bind['namespace'] . '\\' . $class, $method], 'params' => []];