tags:

views:

521

answers:

4

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.

+1  A: 

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
?>
Ross
A: 

@Ross

I thought that getcwd() was returning a filesystem path rather than a relative url path.

Either way, the fact remains that the path /mnt/dev-windows doesn't exist while /mnt/dev-windows-data does.

Mark Biek
A: 

@Mark

Well that's just plain wierd! What's your include_path - that could be messing thigns around. I've personally ditched it in favour of contants as it's just so temperamental (or I've never learned how to do it justice).

Ross
A: 

@Ross

I figured it out and updated the OP with the solution.

Mark Biek