php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23337 dirname() returns incorrect value.
Submitted: 2003-04-24 15:38 UTC Modified: 2003-04-30 12:37 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:3 (100.0%)
From: cyborg at driverheaven dot net Assigned:
Status: Closed Package: *General Issues
PHP Version: 5CVS-2003-04-24 (dev) OS: Windows 2000/XP/2003
Private report: No CVE-ID: None
 [2003-04-24 15:38 UTC] cyborg at driverheaven dot net
<?php
$string = "C:/web_home/deluxe_mail/test.php";
$dir1   = dirname($string);
$dir2   = substr($string, 0, strrpos($string, '/'));

echo $dir1; // Outputs C:/web_home/deluxe_ma
echo $dir2; // Outputs C:/web_home/deluxe_mail
?>

dirname() obviously returns the wrong result in this case, and happens in Windows 2000 Professional, Windows 2000 Advanced Server, Windows XP Professional, as well as Windows 2003 Enterprise Server.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-25 17:01 UTC] sniper@php.net
What's the exact PHP version in phpinfo() output?

 [2003-04-25 18:26 UTC] cyborg at driverheaven dot net
Well it's happened for the last week, including a release from today, but the current release I am using right now is: Apr 25 2003 20:09:15. (I assume that's what you wanted)
 [2003-04-28 10:44 UTC] thixit at yahoo dot com
I also experienced this problem with Build date of Apr 28 2003 12:09:53.
It seems that the problem happened when dirname()'s argument contains a drive letter.
 [2003-04-30 06:12 UTC] sniper@php.net
I wanted to know what PHP VERSION it is, NOT when it's build..

 [2003-04-30 06:26 UTC] wez@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

Fixed yesterday.
 [2003-04-30 12:37 UTC] cyborg at driverheaven dot net
I reported the Version in the report. 5CVS-2003-04-24 (dev), upon which I updated you guys on the fact that I updated to the latest build. (Still 5.0.x-dev), in any case, the bug is fixed. :)
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 18:00:01 2026 UTC