howto: output full path of a file – using php

Sometimes you need to know the full path to a file/directory. If you dont know the full path – for example, you are using a webhosting package without shell access – just put this small php script on the server and execute it.

The PHP script prints the full path to the directory it is placed in. Copy the code and paste it into a file and call it mypath.php or something like that. Execute to see where you are.

<?php
 
 $dir = dirname(__FILE__);
 echo "path to this directory: " . $dir ;

?>

you might also use:

<?php

   echo " path: " . $_SERVER['DOCUMENT_ROOT'];

?>

GL & HF!

Leave a Comment