How to use chdir to change in the current directory?

I am trying to include a file from another directory and then return chdir to the current / original form.

chdir('/some/path'); include(./file.php); chdir();//How to I change the directory back to the original form? 

Anyway, to change chdir back to where the .php file is? or do i need to do it manually?

+4
source share
3 answers

First you need to save the current path before changing dirs:

 $oldPath = getcwd(); chdir('/some/path'); include(./file.php); chdir($oldPath); 

Why do you need to change dirs to include a file?

+7
source

Save the current directory ( getcwd ) before you chdir . Then chdir back.

0
source

You can do this: chdir ('../'); But really not sure about the right behavior

0
source

All Articles