|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29345 Working directory has changed
Submitted: 2004-07-23 01:24 UTC Modified: 2004-07-30 11:31 UTC
From: jeroen at kessels dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 5.0.0 OS: Windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
9 - 1 = ?
Subscribe to this entry?

 [2004-07-23 01:24 UTC] jeroen at kessels dot com
In PHP4 the working directory is the directory where the script lives. In PHP5 it's the root of the website. This has a huge impact on scripts that use the filesystem functions to access local files.

For example, the getcwd() function in a script called "c:/inetpub/wwwroot/work/test.php" will report "c:\inetpub\wwwroot\work" on PHP4, and "c:\inetpub\wwwroot" on PHP5.

I have only Windows 2000 with IIS at my disposal, I've not tested on Linux and Apache.

Reproduce code:
echo getcwd();

Expected result:
The directory where the script lives.

Actual result:
The home directory of the website.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-30 00:38 UTC]
Which sapi are you using? If its cgi please make sure to use php-cgi.exe
 [2004-07-30 02:21 UTC] jeroen at kessels dot com
Ah! Yes, changing to "php-cgi.exe" solves the problem. I followed the manual installation instructions (the "install.txt" file in the ZIP download), which clearly say to use "php.exe". I guess it needs to be rewritten. I can't find any information about the "php-cgi.exe" program, not there and not on this website.
 [2004-07-30 11:31 UTC]
Fixed install.txt will be included in the next release.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Jan 27 19:03:58 2023 UTC