static function getDocumentRoot()
    {
        //The old method is to use the document_root from $_SERVER
        //Howerver in some hosting the document root is not the same
        //with the root folder of the website, so we add backup with
        //second way  to calculate the document root with script_name 
        //and script_filename
        $old_way = str_replace("\\", "/", realpath($_SERVER["DOCUMENT_ROOT"]));
        $script_filename = str_replace(
            "\\",
            "/",
            realpath($_SERVER["SCRIPT_FILENAME"])
        );
        $script_name = str_replace("\\", "/", realpath($_SERVER["SCRIPT_NAME"]));
        $new_way = str_replace($script_name, "", $script_filename);
        
        if ($old_way==$new_way) {
            return $old_way;
        } else if (is_dir($old_way)) {
            return $old_way;
        } else {
            return $new_way;
        }
    }
static function getDocumentRoot()
    {
        //The old method is to use the document_root from $_SERVER
        //Howerver in some hosting the document root is not the same
        //with the root folder of the website, so we add backup with
        //second way  to calculate the document root with script_name 
        //and script_filename
        $old_way = str_replace("\\", "/", realpath($_SERVER["DOCUMENT_ROOT"]));
        $script_filename = str_replace(
            "\\",
            "/",
            realpath($_SERVER["SCRIPT_FILENAME"])
        );
        $script_name = str_replace("\\", "/", realpath($_SERVER["SCRIPT_NAME"]));
        $new_way = str_replace($script_name, "", $script_filename);
        
        if ($old_way==$new_way) {
            return $old_way;
        } else if (is_dir($old_way)) {
            return $old_way;
        } else {
            return $new_way;
        }
    }
static function getDocumentRoot ( ) { //The old method is to use the document_root from $_SERVER //Howerver in some hosting the document root is not the same //with the root folder of the website, so we add backup with //second way  to calculate the document root with script_name  //and script_filename $ old_way = str_replace ( "\\" , "/" , realpath ( $ _SERVER [ "DOCUMENT_ROOT" ] ) ) ; $ script_filename = str_replace ( "\\" , "/" , realpath ( $ _SERVER [ "SCRIPT_FILENAME" ] ) ) ; $ script_name = str_replace ( "\\" , "/" , realpath ( $ _SERVER [ "SCRIPT_NAME" ] ) ) ; $ new_way = str_replace ( $ script_name , "" , $ script_filename ) ; if ( $ old_way == $ new_way ) { return $ old_way ; } else if ( is_dir ( $ old_way ) ) { return $ old_way ; } else { return $ new_way ; } }
Get the doument root

@return string the document root path
Get the doument root