src/App.php
public function url($page = [], $needRequestUri = false, $extra_args = [])
    {
        if ($needRequestUri) {
            return $_SERVER['REQUEST_URI'];
        }

        $sticky = $this->sticky_get_arguments;
        $result = $extra_args;

        if ($this->page === null) {
            $uri = $this->getRequestURI();

            if (substr($uri, -1, 1) == '/') {
                $this->page = 'index';
            } else {
                $this->page = basename($uri, '.php');
            }
        }

        // if page passed as string, then simply use it
        if (is_string($page)) {
            return $page;
        }

        // use current page by default
        if (!isset($page[0])) {
            $page[0] = $this->page;
        }

        //add sticky arguments
        if (is_array($sticky) && !empty($sticky)) {
            foreach ($sticky as $key => $val) {
                if ($val === true) {
                    if (isset($_GET[$key])) {
                        $val = $_GET[$key];
                    } else {
                        continue;
                    }
                }
                if (!isset($result[$key])) {
                    $result[$key] = $val;
                }
            }
        }

        // add arguments
        foreach ($page as $arg => $val) {
            if ($arg === 0) {
                continue;
            }

            if ($val === null || $val === false) {
                unset($result[$arg]);
            } else {
                $result[$arg] = $val;
            }
        }

        // put URL together
        $args = http_build_query($result);
        $url = ($page[0] ? $page[0].'.php' : '').($args ? '?'.$args : '');

        return $url;
    }
public function url($page = [], $needRequestUri = false, $extra_args = [])
    {
        if ($needRequestUri) {
            return $_SERVER['REQUEST_URI'];
        }

        $sticky = $this->sticky_get_arguments;
        $result = $extra_args;

        if ($this->page === null) {
            $uri = $this->getRequestURI();

            if (substr($uri, -1, 1) == '/') {
                $this->page = 'index';
            } else {
                $this->page = basename($uri, '.php');
            }
        }

        // if page passed as string, then simply use it
        if (is_string($page)) {
            return $page;
        }

        // use current page by default
        if (!isset($page[0])) {
            $page[0] = $this->page;
        }

        //add sticky arguments
        if (is_array($sticky) && !empty($sticky)) {
            foreach ($sticky as $key => $val) {
                if ($val === true) {
                    if (isset($_GET[$key])) {
                        $val = $_GET[$key];
                    } else {
                        continue;
                    }
                }
                if (!isset($result[$key])) {
                    $result[$key] = $val;
                }
            }
        }

        // add arguments
        foreach ($page as $arg => $val) {
            if ($arg === 0) {
                continue;
            }

            if ($val === null || $val === false) {
                unset($result[$arg]);
            } else {
                $result[$arg] = $val;
            }
        }

        // put URL together
        $args = http_build_query($result);
        $url = ($page[0] ? $page[0].'.php' : '').($args ? '?'.$args : '');

        return $url;
    }
public function url ( $ page = [ ] , $ needRequestUri = false , $ extra_args = [ ] ) { if ( $ needRequestUri ) { return $ _SERVER [ 'REQUEST_URI' ] ; } $ sticky = $ this -> sticky_get_arguments ; $ result = $ extra_args ; if ( $ this -> page === null ) { $ uri = $ this -> getRequestURI ( ) ; if ( substr ( $ uri , - 1 , 1 ) == '/' ) { $ this -> page = 'index' ; } else { $ this -> page = basename ( $ uri , '.php' ) ; } } // if page passed as string, then simply use it if ( is_string ( $ page ) ) { return $ page ; } // use current page by default if ( ! isset ( $ page [ 0 ] ) ) { $ page [ 0 ] = $ this -> page ; } //add sticky arguments if ( is_array ( $ sticky ) && ! empty ( $ sticky ) ) { foreach ( $ sticky as $ key => $ val ) { if ( $ val === true ) { if ( isset ( $ _GET [ $ key ] ) ) { $ val = $ _GET [ $ key ] ; } else { continue ; } } if ( ! isset ( $ result [ $ key ] ) ) { $ result [ $ key ] = $ val ; } } } // add arguments foreach ( $ page as $ arg => $ val ) { if ( $ arg === 0 ) { continue ; } if ( $ val === null || $ val === false ) { unset ( $ result [ $ arg ] ) ; } else { $ result [ $ arg ] = $ val ; } } // put URL together $ args = http_build_query ( $ result ) ; $ url = ( $ page [ 0 ] ? $ page [ 0 ] . '.php' : '' ) . ( $ args ? '?' . $ args : '' ) ; return $ url ; }
Build a URL that application can use for loading HTML data.

@param array|string $page           URL as string or array with page name as first element and other GET arguments
@param bool         $needRequestUri Simply return $_SERVER['REQUEST_URI'] if needed
@param array        $extra_args     Additional URL arguments

@return string
Build a URL that application can use for loading HTML data .