public function getAuthCredentialsWithBasic()
    {
        if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
            
            return [$_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']];
        } 
        
        $authToken = isset($_SERVER['HTTP_AUTHORIZATION']) ? $_SERVER['HTTP_AUTHORIZATION'] : null;
        $authToken = (!$authToken && isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) 
            ? $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] 
            : $authToken;
        
        if ($authToken !== null && strpos(strtolower($_SERVER['HTTP_AUTHORIZATION']), 'basic ')===0) {
            
            $parts = array_map(function ($value) {
                return strlen($value) === 0 ? null : $value;
            }, explode(':', base64_decode(mb_substr($authToken, 6)), 2));
            
            if (count($parts) < 2) {
                return [$parts[0], null];
            }
            
            return $parts;
        }

        return [null, null];
    }
public function getAuthCredentialsWithBasic()
    {
        if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
            
            return [$_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']];
        } 
        
        $authToken = isset($_SERVER['HTTP_AUTHORIZATION']) ? $_SERVER['HTTP_AUTHORIZATION'] : null;
        $authToken = (!$authToken && isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) 
            ? $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] 
            : $authToken;
        
        if ($authToken !== null && strpos(strtolower($_SERVER['HTTP_AUTHORIZATION']), 'basic ')===0) {
            
            $parts = array_map(function ($value) {
                return strlen($value) === 0 ? null : $value;
            }, explode(':', base64_decode(mb_substr($authToken, 6)), 2));
            
            if (count($parts) < 2) {
                return [$parts[0], null];
            }
            
            return $parts;
        }

        return [null, null];
    }
public function getAuthCredentialsWithBasic ( ) { if ( isset ( $ _SERVER [ 'PHP_AUTH_USER' ] ) && isset ( $ _SERVER [ 'PHP_AUTH_PW' ] ) ) { return [ $ _SERVER [ 'PHP_AUTH_USER' ] , $ _SERVER [ 'PHP_AUTH_PW' ] ] ; } $ authToken = isset ( $ _SERVER [ 'HTTP_AUTHORIZATION' ] ) ? $ _SERVER [ 'HTTP_AUTHORIZATION' ] : null ; $ authToken = ( ! $ authToken && isset ( $ _SERVER [ 'REDIRECT_HTTP_AUTHORIZATION' ] ) ) ? $ _SERVER [ 'REDIRECT_HTTP_AUTHORIZATION' ] : $ authToken ; if ( $ authToken !== null && strpos ( strtolower ( $ _SERVER [ 'HTTP_AUTHORIZATION' ] ) , 'basic ' ) === 0 ) { $ parts = array_map ( function ( $ value ) { return strlen ( $ value ) === 0 ? null : $ value ; } , explode ( ':' , base64_decode ( mb_substr ( $ authToken , 6 ) ) , 2 ) ) ; if ( count ( $ parts ) < 2 ) { return [ $ parts [ 0 ] , null ] ; } return $ parts ; } return [ null , null ] ; }
Get Credentials with HTTP Basic Authentication

@return array that contains exactly two elements:
- 0: the username sent via HTTP authentication, `null` if the username is not given
- 1: the password sent via HTTP authentication, `null` if the password is not given

@example
list($username, $password) = $request->getAuthCredentialsWithBasic();
Get Credentials with HTTP Basic Authentication