PHP: translate virtual path to physical path

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

eg. if I have a url:

/home/index.php

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

+3
source share
2 answers

Are you looking for realpath

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

Prepare $_SERVER["DOCUMENT_ROOT"]the script for the path.

+5
source

Source: https://habr.com/ru/post/1732823/


All Articles