我怎么能没有写所有路径chdir()

So I have this piece of code and all I need is to sort my files by date and I don't know what that code does and why do I need to change chdir, but when after resorting I put it back it works just fine, but one MINUS is that I have to write all path by my hand, how I can just set it to "public_html"?

        $dir = "files";
        chdir($dir); // "Returns TRUE on success or FALSE on failure" 
        array_multisort(array_map('filemtime', ($filesArray = glob("*.*"))), SORT_DESC, $filesArray); //Tipo sortina kazkaip magiskai
        $dir = "/home/galgalda/domains/tortonas.tk/public_html"; //How do i change this line?
        chdir($dir); 

Yo can try using $_SERVER['DOCUMENT_ROOT']

$dir = "files";
chdir($dir); // "Returns TRUE on success or FALSE on failure" 
array_multisort(array_map('filemtime', ($filesArray = glob("*.*"))), SORT_DESC, 
$filesArray); //Tipo sortina kazkaip magiskai
$dir = $_SERVER['DOCUMENT_ROOT']; //How do i change this line?
chdir($dir);