how to use chdir to change to current directory?

前端 未结 3 1143
醉话见心
醉话见心 2020-12-19 09:33

I\'m trying to include a file from another directory and then change the chdir back to the current/original form.

chdir(\'/some/path\');
include(./file.php);         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-19 09:59

    First you need to store the current path, before changing dirs:

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

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

提交回复
热议问题