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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mborchert71 at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 06:01:32 2025 UTC