From 5119bbe470adb863dd08f55cbe4d8ac23a8d42eb Mon Sep 17 00:00:00 2001 From: Muhammad Arsalan Siddiqui Date: Sun, 2 Jul 2023 18:50:21 +0500 Subject: [PATCH] Update router.php Notice: Undefined offset: 0 in router.php on line 56 --- router.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/router.php b/router.php index 1148bee..a02f839 100644 --- a/router.php +++ b/router.php @@ -53,15 +53,15 @@ function route($route, $path_to_include) $request_url_parts = explode('/', $request_url); array_shift($route_parts); array_shift($request_url_parts); - if ($route_parts[0] == '' && count($request_url_parts) == 0) { - // Callback function - if (is_callable($callback)) { - call_user_func_array($callback, []); - exit(); - } - include_once __DIR__ . "/$path_to_include"; - exit(); - } +if (count($route_parts) > 0 && $route_parts[0] == '' && count($request_url_parts) == 0) { + // Callback function + if (is_callable($callback)) { + call_user_func_array($callback, []); + exit(); + } + include_once __DIR__ . "/$path_to_include"; + exit(); +} if (count($route_parts) != count($request_url_parts)) { return; }