PDA

View Full Version : chdir


bahbah
Sat 4th Jun '05, 11:42am
Hi,

I was hoping someone could help me to understand chdir properly.

I need to use chdir to require a script.

By chdir'ing I am able to require the script properly.

By chdir'ing one of the other scripts on the same page breaks.

For example:

If I have a php script includes others. Where is that script executed ?

If I have a php script with a require that uses chdir. Where is that script executed ?

If I have a php script with 2 requires that uses a chdir for one of them where is the script initially executed ? and would chdiring back to this location allow the other script to run ?

Confused ? Me too!

Thanks

Steve Machol
Sat 4th Jun '05, 2:15pm
Are you running on a Windows server by any chance? I've seen some Windows servers have problems with the chdir function.

bahbah
Sat 4th Jun '05, 3:11pm
Linux thanks Steve

Razz
Mon 6th Jun '05, 5:20pm
I'm not 100% sure on this as I have never needed to use it yet in a script, but I'm sure that if you're using relative paths in your includes, once you use chdir you need to allow for the directory change in your relative paths.

Ken Iovino
Sat 11th Jun '05, 8:38am
chdir(); Is pretty simple to understand.

I use this on my site for my custom portal page. In my /root/index.php file i have this:

chdir('/home/vbhacker/public_html/forum/');
require_once('./global.php');
require_once('./includes/functions_bbcodeparse.php');


What that does is places my index.php file in the /root/forum/ enviorment. It doesn't acually move it there, but it munipulates the code to belive its there.