php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54536 dirname() and basename() documentation unclear/incorrect for Windows
Submitted: 2011-04-15 06:31 UTC Modified: 2013-02-12 02:56 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: chealer at gmail dot com Assigned: googleguy (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: chealer at gmail dot com
New email:
PHP Version: OS:

 

 [2011-04-15 06:31 UTC] chealer at gmail dot com
Description:
------------
Hi,
earlier I reported http://bugs.php.net/bug.php?id=53401 about the documentation for basename and dirname, which was partly addressed by revision 308194, but there are still a few issues, in particular for Windows. Again this bug report is wide.
http://www.php.net/manual/en/function.dirname.php
http://www.php.net/manual/en/function.basename.php

The basename page describes the return value:

Returns the base name of the given path.

But a path can have no basename if it has no component.

Also, the suffix parameter is described:

If the name component ends in suffix this will also be cut off.

The path can have several filename components, I suppose this should read:

If the basename ends in suffix this will also be cut off.


The dirname page has more Windows-specific issues. Problems are mostly with edge cases. The following is said about the return value:

If there are no slashes in path, a dot ('.') is returned, indicating the current directory. Otherwise, the returned string is path with any trailing /component removed. 

As shown in example 2, even if there is a slash, the operation is more complex than removing a trailing slash followed by a component. dirname can also remove a slash followed by a component followed by a slash. And this is only valid on UNIX; on Windows backslashes are considered too.

dirname documentation refers to the parent directory, but eventually, there is no more parent directory (like for "/").


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-16 12:46 UTC] googleguy@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: googleguy
 [2013-01-16 12:46 UTC] googleguy@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2013-02-12 02:56 UTC] chealer at gmail dot com
Would you please explain how this was solved?
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 13:00:01 2026 UTC