Edit report at https://bugs.php.net/bug.php?id=62967&edit=1

 ID:                 62967
 Updated by:         [email protected]
 Reported by:        360586201 at qq dot com
 Summary:            执行析构函数时工作目录有问题
-Status:             Analyzed
+Status:             Closed
 Type:               Bug
 Package:            *Directory/Filesystem functions
 PHP Version:        5.3.16
-Assigned To:        
+Assigned To:        laruence
 Block user comment: N
 Private report:     N

 New Comment:

哦, 这个问题之前已经有人报告过了, 
也已经在文档中注明了.  参见 #34206

closed, see #34206

http://php.net/manual/en/language.oop5.decon.php


Previous Comments:
------------------------------------------------------------------------
[2012-08-29 14:22:05] 360586201 at qq dot com

这是算一个bug吧?那是不修复了?

------------------------------------------------------------------------
[2012-08-29 14:19:19] [email protected]

__destruct被调用的时候, 当前脚本已经完成了执行, 
进入了request shutdown时期, 所以, 此时的工作
目录变成了apache的工作目录.
while the __destruct was calling, the script had already be executed, and it 
has 
enter the request shutdown phase. so the current work dir became to the 
apache's .

我大体看了下, 要修复这个, 我们需要花费比较大的改动. 
有些昂贵

I'd like mark this as won't fix.

------------------------------------------------------------------------
[2012-08-29 14:12:53] 360586201 at qq dot com

DocumentRoot "D:/www/"

------------------------------------------------------------------------
[2012-08-29 14:09:09] [email protected]

你的DocumentRoot设置的是?

------------------------------------------------------------------------
[2012-08-29 13:25:57] 360586201 at qq dot com

Description:
------------
在析构函数的当前工作目录竟然变为了apache目录

更奇怪的是,我不执行普通方法时,析构函数的工作目录是正确的,也是代码的执行目录,当我执行过普
通方法后,就一直为apache目录了


Test script:
---------------
<?php
class get_path {
        function __construct() {
                //获取当前工作路径
                echo getcwd().'<br>';  #输出 D:\www\test(代码执行目录)
        }

        function write() {
                //获取当前工作路径
                echo getcwd().'<br>';  #输出 D:\www\test(代码执行目录)
        }

        function __destruct() {
                //获取当前工作路径
                echo getcwd();  #输出 D:\Program 
Files\wamp\bin\apache\Apache2.2.21(apache目录)
        }
}

$gl = new get_path();
$gl->write();



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62967&edit=1

Reply via email to