src/classes/Http/Request.php
public static function fromGlobals()
    {
        $request = new self();

        foreach ([
            'Accept', 'Accept-Charset', 'Accept-Encoding', 'Accept-Language',
            'Connection', 'Host', 'Referer', 'User-Agent'
        ] as $name) {
            $key = 'HTTP_' . str_replace('-', '_', strtoupper($name));
            if (isset($_SERVER[$key])) {
                $request->setHeader($name, $_SERVER[$key], false);
            }
        }

        $request->_isSecure = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off');

        $request->_method = $_SERVER['REQUEST_METHOD'];
        $request->_uri = $_SERVER['REQUEST_URI'];

        $request->_path = strstr($_SERVER['REQUEST_URI'], '?', true);
        if ($request->_path == false) {
            $request->_path = $_SERVER['REQUEST_URI'];
        }
        $request->_query = strstr($_SERVER['REQUEST_URI'], '?');
        if ($request->_query == false) {
            $request->_query = '';
        }

        return $request;
    }
public static function fromGlobals()
    {
        $request = new self();

        foreach ([
            'Accept', 'Accept-Charset', 'Accept-Encoding', 'Accept-Language',
            'Connection', 'Host', 'Referer', 'User-Agent'
        ] as $name) {
            $key = 'HTTP_' . str_replace('-', '_', strtoupper($name));
            if (isset($_SERVER[$key])) {
                $request->setHeader($name, $_SERVER[$key], false);
            }
        }

        $request->_isSecure = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off');

        $request->_method = $_SERVER['REQUEST_METHOD'];
        $request->_uri = $_SERVER['REQUEST_URI'];

        $request->_path = strstr($_SERVER['REQUEST_URI'], '?', true);
        if ($request->_path == false) {
            $request->_path = $_SERVER['REQUEST_URI'];
        }
        $request->_query = strstr($_SERVER['REQUEST_URI'], '?');
        if ($request->_query == false) {
            $request->_query = '';
        }

        return $request;
    }
public static function fromGlobals ( ) { $ request = new self ( ) ; foreach ( [ 'Accept' , 'Accept-Charset' , 'Accept-Encoding' , 'Accept-Language' , 'Connection' , 'Host' , 'Referer' , 'User-Agent' ] as $ name ) { $ key = 'HTTP_' . str_replace ( '-' , '_' , strtoupper ( $ name ) ) ; if ( isset ( $ _SERVER [ $ key ] ) ) { $ request -> setHeader ( $ name , $ _SERVER [ $ key ] , false ) ; } } $ request -> _isSecure = ( ! empty ( $ _SERVER [ 'HTTPS' ] ) && $ _SERVER [ 'HTTPS' ] != 'off' ) ; $ request -> _method = $ _SERVER [ 'REQUEST_METHOD' ] ; $ request -> _uri = $ _SERVER [ 'REQUEST_URI' ] ; $ request -> _path = strstr ( $ _SERVER [ 'REQUEST_URI' ] , '?' , true ) ; if ( $ request -> _path == false ) { $ request -> _path = $ _SERVER [ 'REQUEST_URI' ] ; } $ request -> _query = strstr ( $ _SERVER [ 'REQUEST_URI' ] , '?' ) ; if ( $ request -> _query == false ) { $ request -> _query = '' ; } return $ request ; }
Create request from PHP globals.
Create request from PHP globals .