SERVER variable of DOCUMENT_ROOT in windows hosting

PHP Add comments

One of my projects was uploaded to a windows hosting and i found server of document root was not working. So i searched and i found the following gimmick of using it in windows hosting.

if ( ! isset($_SERVER['DOCUMENT_ROOT'] ) )
  $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr(
    $_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF']) ) );

Leave a Reply

Entries RSS