Search code examples
phpiisserver-variables

DOCUMENT ROOT variable on PHP-IIS


Does the $_SERVER["DOCUMENT_ROOT"] variable exist on IIS running PHP? Earlier I thought this variable is Apache specific and on IIS, you have to emulate it by string manipulation of SCRIPT_NAME and SCRIPT_FILENAME variables but I now see this variable on my PHP installation on IIS. Is it safe to assume that this variable will always be available on IIS.


Solution

  • Is it safe to assume doc root is always available in IIS? No...

    $_SERVER['DOCUMENT_ROOT'] is not always available on IIS.. it has to be set in the config file...

    If it is configured on your server you 'could' use it... Just make sure your config file doesn't change - otherwise you will break your scripts...