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?
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.