public function extractRoute()
    {
        $requestUri = $this->getServer('REQUEST_URI');
        $scriptName = $this->getServer('SCRIPT_NAME');
        $scriptPath = dirname($scriptName);
        $scriptFile = basename($scriptName);

        $requestUri = urldecode($requestUri);

        // Compare REQUEST_URI and SCRIPT_NAME as long they match,
        // leave the rest as current request.
        $i = 0;
        $len = min(strlen($requestUri), strlen($scriptPath));
        while ($i < $len
               && $requestUri[$i] == $scriptPath[$i]
        ) {
            $i++;
        }
        $route = trim(substr($requestUri, $i), '/');

        // Does the request start with script-name - remove it.
        $len1 = strlen($route);
        $len2 = strlen($scriptFile);

        if ($len2 <= $len1
            && substr_compare($scriptFile, $route, 0, $len2, true) === 0
        ) {
            $route = substr($route, $len2 + 1);
        }

        // Remove the ?-part from the query when analysing controller/metod/arg1/arg2
        $queryPos = strpos($route, '?');
        if ($queryPos !== false) {
            $route = substr($route, 0, $queryPos);
        }

        $route = ($route === false) ? '' : $route;

        $this->route = $route;
        $this->routeParts = explode('/', trim($route, '/'));

        return $this->route;
    }
public function extractRoute()
    {
        $requestUri = $this->getServer('REQUEST_URI');
        $scriptName = $this->getServer('SCRIPT_NAME');
        $scriptPath = dirname($scriptName);
        $scriptFile = basename($scriptName);

        $requestUri = urldecode($requestUri);

        // Compare REQUEST_URI and SCRIPT_NAME as long they match,
        // leave the rest as current request.
        $i = 0;
        $len = min(strlen($requestUri), strlen($scriptPath));
        while ($i < $len
               && $requestUri[$i] == $scriptPath[$i]
        ) {
            $i++;
        }
        $route = trim(substr($requestUri, $i), '/');

        // Does the request start with script-name - remove it.
        $len1 = strlen($route);
        $len2 = strlen($scriptFile);

        if ($len2 <= $len1
            && substr_compare($scriptFile, $route, 0, $len2, true) === 0
        ) {
            $route = substr($route, $len2 + 1);
        }

        // Remove the ?-part from the query when analysing controller/metod/arg1/arg2
        $queryPos = strpos($route, '?');
        if ($queryPos !== false) {
            $route = substr($route, 0, $queryPos);
        }

        $route = ($route === false) ? '' : $route;

        $this->route = $route;
        $this->routeParts = explode('/', trim($route, '/'));

        return $this->route;
    }
public function extractRoute ( ) { $ requestUri = $ this -> getServer ( 'REQUEST_URI' ) ; $ scriptName = $ this -> getServer ( 'SCRIPT_NAME' ) ; $ scriptPath = dirname ( $ scriptName ) ; $ scriptFile = basename ( $ scriptName ) ; $ requestUri = urldecode ( $ requestUri ) ; // Compare REQUEST_URI and SCRIPT_NAME as long they match, // leave the rest as current request. $ i = 0 ; $ len = min ( strlen ( $ requestUri ) , strlen ( $ scriptPath ) ) ; while ( $ i < $ len && $ requestUri [ $ i ] == $ scriptPath [ $ i ] ) { $ i ++ ; } $ route = trim ( substr ( $ requestUri , $ i ) , '/' ) ; // Does the request start with script-name - remove it. $ len1 = strlen ( $ route ) ; $ len2 = strlen ( $ scriptFile ) ; if ( $ len2 <= $ len1 && substr_compare ( $ scriptFile , $ route , 0 , $ len2 , true ) === 0 ) { $ route = substr ( $ route , $ len2 + 1 ) ; } // Remove the ?-part from the query when analysing controller/metod/arg1/arg2 $ queryPos = strpos ( $ route , '?' ) ; if ( $ queryPos !== false ) { $ route = substr ( $ route , 0 , $ queryPos ) ; } $ route = ( $ route === false ) ? '' : $ route ; $ this -> route = $ route ; $ this -> routeParts = explode ( '/' , trim ( $ route , '/' ) ) ; return $ this -> route ; }
Extract the part containing the route.

@return string as the current extracted route
Extract the part containing the route .