Original script directory in PHP

Magic constant __DIR__ is the directory of the current script, but what if I need the directory of the script that included or required it, i.e., the original script? Is there something like a __ORIGINALDIR__?

In particular, if the directory of the current script equals the directory of the original script then we should get __ORIGINALDIR__ === __DIR__.

Upvotes: 1

Views: 85

Answers (1)

Starx
Starx

Reputation: 78971

Like this

echo dirname($_SERVER['SCRIPT_NAME']);

Upvotes: 1

Related Questions