#36956 [Opn->Fbk]: dirname returns \ for root /
ID: 36956
Updated by: sniper@php.net
Reported By: e dot vandeoudeweetering at marcanti dot esprit-sg dot
-Status: Open
+Status: Feedback
Bug Type: Directory function related
Operating System: Windows 2000 (5.00.2195) SP4
PHP Version: 5.1.2
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.1-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.1-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2006-04-04 11:58:35] e dot vandeoudeweetering at marcanti dot
esprit-sg dot
I did check the following documentation:
http://nl3.php.net/manual/en/function.dirname.php
dirname('c:/');
it returns c:\ (notice the backslash)
the documentation says it should return c:
suggest the following 7 examles:
$dir = 'C:\\Temp';
print "$dir\t\t: ".dirname($dir).'\\'.basename($dir)."\n";
$dir = 'C:/Temp';
print "$dir\t\t: ".dirname($dir).'/'.basename($dir)."\n";
$dir = 'C:\\';
print "$dir\t\t: ".dirname($dir).'\\'.basename($dir)."\n";
$dir = 'C:/';
print "$dir\t\t: ".dirname($dir).'/'.basename($dir)."\n";
$dir = '\\\\server\\share';
print "$dir\t: ".dirname($dir).'\\'.basename($dir)."\n";
$dir = '//server/share';
print "$dir\t: ".dirname($dir).'/'.basename($dir)."\n";
$dir = '/usr/local';
print "$dir\t: ".dirname($dir).'/'.basename($dir)."\n";
The following output is generated:
C:\Temp : C:\\Temp
C:/Temp : C:\/Temp
C:\ : C:\\C:
C:/ : C:\/C:
\\server\share : \\server\share
//server/share : //server/share
/usr/local : /usr/local
The following output is expected:
C:\Temp : C:\Temp
C:/Temp : C:/Temp
C:\ : C:\
C:/ : C:/
\\server\share : \\server\share
//server/share : //server/share
/usr/local : /usr/local
As you see something is wrong!
------------------------------------------------------------------------
[2006-04-04 09:27:14] tony2001@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is expected, as Window$ uses \ everywhere instead of / on *nix.
------------------------------------------------------------------------
[2006-04-03 13:33:19] e dot vandeoudeweetering at marcanti dot
esprit-sg dot
Description:
------------
When using the function dirname, \ is returned for the root directory
/
This is what the documentation says:
//after PHP 4.3.0
dirname('c:/'); // returns 'c:'
Reproduce code:
---------------
print dirname('/');
print dirname('C:/');
print dirname('C:\\'); //this function works
Expected result:
----------------
/
C:
C:\
Actual result:
--------------
\
C:\
C:\
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36956&edit=1
Thread (7 messages)