php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #51830 dirname() and basename() documentation unclear/incorrect
Submitted: 2010-05-14 22:41 UTC Modified: 2010-11-07 04:56 UTC
From: chealer at gmail dot com Assigned: frozenfire (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2010-05-14 22:41 UTC] chealer at gmail dot com
Description:
------------
The dirname() documentation, at http://www.php.net/manual/en/function.dirname.php , says that "Given a string containing a path to a file, this function will return the name of the directory.", This is either incomprehensible, or at best, ambiguous. Which directory? If giving a directory pathname, one would assume the given directory's pathname would be returned, but that is not the case.

The basename() documentation is also wrong. It says the base name of the file given is returned. What's returned is not the base name, but the [POSIX] basename (without a space).

Back to dirname(), it says:
Returns the name of the directory. 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.

This description must be copied from the coreutils dirname manpage, on which I filed a bug:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6175

The POSIX manpage is better, but non-free. As an alternative, I suggest to use coreutils dirname's info page. In addition to the issue in coreutils dirname's manpage, the description is not adapted to Windows.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-17 08:37 UTC] aharvey@php.net
-Type: Bug +Type: Documentation Problem
 [2010-10-25 22:06 UTC] kalle@php.net
Internally we do not use the dirname() and basename() functions from the coreutils package, we have our own custom implementations of those in php, see php_basename() and zend_dirname() but I do not know if those implementations are identical to ours, so their descriptions might differ.

I agree the basename() return description could be improved a little and the dirname() return value could be abit more specific.
 [2010-11-07 04:55 UTC] frozenfire@php.net
Automatic comment from SVN on behalf of frozenfire
Revision: http://svn.php.net/viewvc/?view=revision&revision=305142
Log: Clarified behaviour of dirname and basename, as per bug #51830.
 [2010-11-07 04:56 UTC] frozenfire@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: frozenfire
 [2010-11-07 04:56 UTC] frozenfire@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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 02:01:33 2024 UTC