public static function getCurrentUrl(): string
    {
        $siteUrl = self::getSiteUrl();
        
        $request = self::getServerVariable('REQUEST_URI', self::getServerVariable('PHP_SELF', ''));
        $query = self::getQueryString();
        
        $indexPhpFound = strpos($request, INDEX_FILE);
        if (!USE_INDEX_FILE && ($indexPhpFound === 0 || $indexPhpFound === 1)) {
            // remove index.php
            $request = str_replace(INDEX_FILE, '', $request);
        }
        
        $currentUrl = $siteUrl . $request;
        if (!empty($query) && strpos($request, $query) === false) {
            $currentUrl .= '?' . $query;
        }
        
        return preg_replace("#([^:])//+#", "$1/", $currentUrl);
    }
public static function getCurrentUrl(): string
    {
        $siteUrl = self::getSiteUrl();
        
        $request = self::getServerVariable('REQUEST_URI', self::getServerVariable('PHP_SELF', ''));
        $query = self::getQueryString();
        
        $indexPhpFound = strpos($request, INDEX_FILE);
        if (!USE_INDEX_FILE && ($indexPhpFound === 0 || $indexPhpFound === 1)) {
            // remove index.php
            $request = str_replace(INDEX_FILE, '', $request);
        }
        
        $currentUrl = $siteUrl . $request;
        if (!empty($query) && strpos($request, $query) === false) {
            $currentUrl .= '?' . $query;
        }
        
        return preg_replace("#([^:])//+#", "$1/", $currentUrl);
    }
public static function getCurrentUrl ( ) : string { $ siteUrl = self :: getSiteUrl ( ) ; $ request = self :: getServerVariable ( 'REQUEST_URI' , self :: getServerVariable ( 'PHP_SELF' , '' ) ) ; $ query = self :: getQueryString ( ) ; $ indexPhpFound = strpos ( $ request , INDEX_FILE ) ; if ( ! USE_INDEX_FILE && ( $ indexPhpFound === 0 || $ indexPhpFound === 1 ) ) { // remove index.php $ request = str_replace ( INDEX_FILE , '' , $ request ) ; } $ currentUrl = $ siteUrl . $ request ; if ( ! empty ( $ query ) && strpos ( $ request , $ query ) === false ) { $ currentUrl .= '?' . $ query ; } return preg_replace ( "#([^:])//+#" , "$1/" , $ currentUrl ) ; }
Get the valid fully qualified URL of the current request.
This also includes a check to see if `index.php` needs to be added or removed from the URL.

@return string

@see https://tools.ietf.org/html/rfc1738
Get the valid fully qualified URL of the current request . This also includes a check to see if index . php needs to be added or removed from the URL .