php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #34206 cwd set to server root (?) in __destruct
Submitted: 2005-08-21 19:11 UTC Modified: 2007-08-20 13:38 UTC
Votes:15
Avg. Score:4.5 ± 0.8
Reproduced:11 of 12 (91.7%)
Same Version:4 (36.4%)
Same OS:7 (63.6%)
From: maniac_warlord at web dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
 [2005-08-21 19:11 UTC] maniac_warlord at web dot de
Description:
------------
cwd is set to server root (i guess) instead of called php file's directory in __destruct()

it probably isn't server root (see results), because that would be /www on linux - on windows it is

Reproduce code:
---------------
<?php
class Foo
{
    public function bar()
    {
            echo getcwd() . "\n";
    }

    public function __destruct()
    {
        $this->bar();
    }
}
$f = new Foo();
$f->bar();
?>

Expected result:
----------------
Windows XP:
F:\htdocs
F:\htdocs

My webhoster's linux:
/www/htdocs/[some number]
/www/htdocs/[some number]

(or whatever directory the file is in)

Actual result:
--------------
Windows XP:
F:\htdocs
D:\Apache\Apache 2

My webhoster's linux:
/www/htdocs/[some number]
/

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-26 11:09 UTC] sniper@php.net
This really should be documented. Apache(1&2) does the weird
cwd change for some reason.

 [2007-07-30 09:56 UTC] hans dot duedal at gmail dot com
I believe this is what's causing bug:29167, as well.
 [2007-08-20 13:38 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"The working directory in the script shutdown phase can be different with some SAPIs (e.g. Apache)."
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 03:01:27 2024 UTC