|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #69263 dirname() removes only some double-slashes
Submitted: 2015-03-19 11:41 UTC Modified: 2015-03-19 19:37 UTC
From: marc at gutt dot it Assigned:
Status: Not a bug Package: Directory function related
PHP Version: 5.4.38 OS: Debian
Private report: No CVE-ID: None
 [2015-03-19 11:41 UTC] marc at gutt dot it
From manual page:

dirname() removes ending double slash, but does not replace double-slash generally. It think the ending "//" should become "/" as this is the parent.

Test script:
echo dirname('') . PHP_EOL;

echo dirname('') . PHP_EOL;

Expected result:
I would expect in both cases one ending slash:
echo dirname('') . PHP_EOL;

echo dirname('') . PHP_EOL;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-19 19:37 UTC]
-Status: Open +Status: Not a bug
 [2015-03-19 19:37 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

Note, that dirname() is supposed to work on paths, and is not
necessarily suited for general URIs.

Also note, that the double slashes in your examples are actually
errors (except the double slashes after the colon following the
 [2015-04-01 14:27 UTC] marc at gutt dot it
Of course this is not a valid path, but sometimes this happens and the OS should ignore multiple slashes at all.

But finally dirname() should remove them or not and not return a mix of both.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jun 19 10:01:24 2021 UTC