ajsie
ajsie

Reputation: 79696

$_SERVER['document_root']?

is this pointing to the directory where the current file is executed?

Upvotes: 2

Views: 1596

Answers (7)

Ben Everard
Ben Everard

Reputation: 13804

'DOCUMENT_ROOT'
The document root directory under which the current script is executing, as defined in the server's configuration file.

http://www.php.net/manual/en/reserved.variables.server.php

Upvotes: 0

Harmen
Harmen

Reputation: 22438

No, it's not,

DOCUMENT_ROOT points to the root directory of your webserver, while PATH_INFO points to the directory where the current file is executed.

Upvotes: 1

Adam Hopkinson
Adam Hopkinson

Reputation: 28795

No, it points to the root of your webserver - the topmost folder of your website.

If you want the directory of the current file, use:

dirname(__FILE__);

Upvotes: 8

Extrakun
Extrakun

Reputation: 19305

Maybe, depending on how the server is set up. A much better method is:

echo dirname(__FILE__); // return the absolute file-path to where the current PHP file is

Upvotes: 1

mattbasta
mattbasta

Reputation: 13709

Yes it is. It's a path relative to the root of your server (not your document root) that describes the directory of the current script. It does not have a trailing slash.

Upvotes: 0

rogeriopvl
rogeriopvl

Reputation: 54066

From http://php.net/manual/en/reserved.variables.server.php

'DOCUMENT_ROOT' The document root directory under which the current script is executing, as defined in the server's configuration file.

Upvotes: 1

SilentGhost
SilentGhost

Reputation: 319601

The document root directory under which the current script is executing, as defined in the server's configuration file.

as the name implies it's a root directory.

Upvotes: 0

Related Questions