Jump to content

[SOLVED] chdir and getcwd() strange behaviour.


alant

Recommended Posts

I'm getting quite frustrated with my chdir function not actually changing the dir on my site. Here's the test code I'm using:
[code]<?php
echo(dirname(__FILE__));
chdir(dirname(__FILE__));
echo getcwd();
?>[/code]

When I echo (dirname(__FILE__)) it correctly echoes the path in which my script is running which is C:\www. But when it gets to echo getcwd() it either echoes C:\www\resources or C:\windows\system32 and when I refresh the page it will occasionally flick back and forth between those two.
Why doesn't it change the directory to C:\www like I asked it too?
well I need to change to the current directory because for some reason the current working directory being reported by getcwd() isn't the directory that my index.php is in. So whenever I want to include another php file or something, instead of it looking for the file relative to my index.php it looks for it under c:\www\resources. My index.php script is located in C:\www not C:\www\resources.
no that doesn't work either, I tried that first. for some reason unknown to me it doesn't want to change my directory, it's beyond me why it is defaulting to my c:\www\resources directory in the first place I have no links to it in my index.php whatsoever. I have a feeling it has something to do with IIS so I've installed apache and will give that a go tomorrow.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.