note 92829 modified in reserved.variables.server by danbrown
| From: | danbrown@php.net | Date: | Tue, 11 Aug 2009 15:22:19 +0000 |
| Subject: | note 92829 modified in reserved.variables.server by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-159331@lists.php.net to get a copy of this message | ||
$_SERVER['DOCUMENT_ROOT'] is incredibly useful especially when working in your development
environment. If you're working on large projects you'll likely be including a large number
of files into your pages. For example:
<?php
//Defines constants to use for "include" URLS - helps keep our paths clean
define("REGISTRY_CLASSES",
$_SERVER['DOCUMENT_ROOT']."/SOAP/classes/");
define("REGISTRY_CONTROLS",
$_SERVER['DOCUMENT_ROOT']."/SOAP/controls/");
define("STRING_BUILDER", REGISTRY_CLASSES. "stringbuilder.php");
define("SESSION_MANAGER", REGISTRY_CLASSES. "sessionmanager.php");
define("STANDARD_CONTROLS", REGISTRY_CONTROLS."standardcontrols.php");
?>
In development environments, you're rarely working with your root folder, especially if
you're running PHP locally on your box and using DOCUMENT_ROOT is a great way to maintain URL
conformity. This will save you hours of work preparing your application for deployment from your box
to a production server (not to mention save you the headache of include path failures).
--was--
$_SERVER['DOCUMENT_ROOT'] is incredibly useful especially when working in your development
environment. If you're working on large projects you'll likely be including a large number
of files into your pages. For example:
<?
//Defines constants to use for "include" URLS - helps keep our paths clean
define("REGISTRY_CLASSES",
$_SERVER['DOCUMENT_ROOT']."/SOAP/classes/");
define("REGISTRY_CONTROLS",
$_SERVER['DOCUMENT_ROOT']."/SOAP/controls/");
define("STRING_BUILDER", REGISTRY_CLASSES. "stringbuilder.php");
define("SESSION_MANAGER", REGISTRY_CLASSES. "sessionmanager.php");
define("STANDARD_CONTROLS", REGISTRY_CONTROLS."standardcontrols.php");
?>
In development environments, you're rarely working with your root folder, especially if
you're running PHP locally on your box and using DOCUMENT_ROOT is a great way to maintain URL
conformity. This will save you hours of work preparing your application for deployment from your box
to a production server (not to mention save you the headache of include path failures).
http://php.net/manual/en/reserved.variables.server.php