Finding Your Current Directory With PHP

Filed under: Web Design

There are times when you are moving to a new host or just when you need to examine where the file you uploaded is located relative to your website.

To do this you can use the PHP command getcwd() this will retreive the Current Working Directory or the location of the file that is being executed.

Simply make a new text file named whereami.php

<?php
echo “you are here” . “n”;
echo getcwd() . “n”;
?>

Upload this file to the directory that you need to get the path to and load it in your browser.

You should remove the file after it is no longer needed.