Example #1
0
        if (preg_match("#{$MatchString}#", $_SERVER['PHP_SELF'], $match) === 1) {
            $ServerString = explode('@', $link);
            $parmas = str_replace($_SERVER['SCRIPT_NAME'] . $match[0] . '/', '', $_SERVER['PHP_SELF']);
            $parmas = explode('/', $parmas);
            $controller = $ServerString[0];
            $action = $ServerString[1];
            unset($ServerString, $match);
            return ['controller' => $controller, 'action' => $action, 'parmas' => $parmas];
        }
    }
    protected function analysistByFunction($MatchString, $link)
    {
        if (preg_match("#{$MatchString}#", $_SERVER['PHP_SELF'], $match) === 1) {
            $link();
            $parmas = str_replace($_SERVER['SCRIPT_NAME'] . $match[0] . '/', '', $_SERVER['PHP_SELF']);
            $parmas = explode('/', $parmas);
            unset($match);
            return $parmas;
        }
    }
    public function responseStatus($status, $callback)
    {
        if (http_response_code() == $status) {
            $callback();
        }
    }
}
$router = new Router();
$router->responseStatus(404, function () {
    echo 'hello';
});