r_honey
r_honey

Reputation: 893

PHP: translate virtual path to physical path

Is it possible to translate a server relative virtual path to physical path in PHP?

e.g. if I have a url:

/home/index.php

then find the physical path of index.php somehow from some other script?

Upvotes: 3

Views: 10595

Answers (2)

Benoît Vidis
Benoît Vidis

Reputation: 3902

You're looking for realpath

$path = 'mydir/index.php';
echo realpath($path);

Upvotes: 8

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798744

Prepend $_SERVER["DOCUMENT_ROOT"] to the script path.

Upvotes: 5

Related Questions