php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #66914 basename("/path/directory/") returns directory
Submitted: 2014-03-16 19:01 UTC Modified: 2016-06-29 14:45 UTC
From: mborchert71 at gmail dot com Assigned: cmb (profile)
Status: Closed Package: *Directory/Filesystem functions
PHP Version: 5.4.26 OS: Linux Debian/Ubuntu/Mint
Private report: No CVE-ID: None
 [2014-03-16 19:01 UTC] mborchert71 at gmail dot com
Description:
------------
basename should return empty string on trailing slash strings

Test script:
---------------
echo basename("/test/path/");//returns path


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-03-16 19:10 UTC] mborchert71 at gmail dot com
Similar "unexpected" is, that

dirname("") returns "."
 [2014-03-20 08:36 UTC] shm@php.net
Accroding to glibc's man basename(3):

[...]
The functions dirname() and basename() break a null-terminated pathname string
into directory and filename components.  In the usual case, dirname()  returns
the string up to, but not including, the final '/', and basename() returns the
component following the final '/'.  Trailing '/' characters are not counted as
part of the pathname.
[...]

Our implementation behaves the same.
 [2014-03-20 16:11 UTC] mborchert71 at gmail dot com
Well, yes. thanks for the enlightenment...
I won'T stand in the way of: POSIX.1-2001.
...
although if find it a bit disturbing that stringHandling with '.' and the finalslash-basename concept...
but thanks anyway.. this maybe closed... or can i close this...
i dont know... it was my "virginity lost" in bug-reports...
;)
 [2016-06-29 14:45 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2016-06-29 14:45 UTC] cmb@php.net
> but thanks anyway.. this maybe closed...

Okay, closing.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 19:01:31 2024 UTC