drwdvftp423507 2008-08-27 14:40
浏览 218
已采纳

为什么getcwd()会返回与本地pwd不同的目录?

I'm doing some PHP stuff on an Ubuntu server.

The path I'm working in is /mnt/dev-windows-data/Staging/mbiek/test_list but the PHP call getcwd() is returning /mnt/dev-windows/Staging/mbiek/test_list (notice how it's dev-windows instead of dev-windows-data).

There aren't any symbolic links anywhere.

Are there any other causes for getcwd() returning a different path from a local pwd call?

Edit

I figured it out. The DOCUMENT_ROOT in PHP is set to /mnt/dev-windows which throws everything off.

  • 写回答

4条回答 默认 最新

  • dongmoyu0336 2008-08-27 14:42
    关注

    Which file are you calling the getcwd() in and is that file is included into the one you are running (e.g. running index.php, including startup.php which contains gwtcwd()).

    Is the file you are running in /dev-windows/ or /dev-windows-data/? It works on the file you are actually running.


    Here's an example of my current project:

    index.php

    <?php
        require_once('./includes/construct.php');
        //snip
    ?>
    

    includes/construct.php

    <?php
        //snip
        (!defined('DIR')) ? define('DIR', getcwd()) : NULL;
    
        require_once(DIR . '/includes/functions.php');
        //snip
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比