Trailing slash at the end of DOCUMENT_ROOT on Apache-Collection of common programming errors

I’ve got a framework I need to work with and the server configuration file for the live version (the working one) specifies the document root like this:

define('DOCUMENT_ROOT', $_SERVER['DOCUMENT_ROOT']);

Now if I try running the framework on my localhost machine I keep getting a server error.

HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

It doesn’t work unless I do this:

define('DOCUMENT_ROOT', $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR);

It works this way, but as a result many directory paths end up like the following:

cannot access '/var/www//tmp/cache/pdfs//case_1240_en': No such file or directory

…with double slashes.

Question: why is such behavior present on the Apache server (the live version is also running on Apache and it works perfectly well without the trailing slash at the end of document root) and how can I remedy this so that $_SERVER['DOCUMENT_ROOT'] works?