Jump to content

Setting DOCUMENT_ROOT to the current directory...

Recommended Posts

Most of the time when I install PHP I get the current directory of the .php file returned from my script. With Zend Server 6 CE DOCUMENT_ROOT seems to be truncating the .php files running directory and is always returning htdocs as the last folder regardless of the fact that my application is actually in /htdocs/samedaycrm/documentroot.php. Is there some way to change the configuration for DOCUMENT_ROOT so that it starts returning the current running directory of the .php file?

Link to post
Share on other sites

The document root setting is the document root of the web server, which is htdocs. That is a web server configuration setting, PHP is only reading the value from the web server. If you want to get the directory of the current script then for PHP 5.3 you can use the __DIR__ constant. Before 5.3 you can use dirname(__FILE__). http://www.php.net/manual/en/language.constants.predefined.php If you look inside the $_SERVER array then you should find other options that you may want to use also.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...