|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #81079 pathinfo() unexpected path/filename separation with trailing slash
Submitted: 2021-05-24 14:57 UTC Modified: 2021-05-25 12:13 UTC
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: info at kgsw dot de Assigned:
Status: Verified Package: *Directory/Filesystem functions
PHP Version: 7.3.28 OS: Linux Mint 20.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: info at kgsw dot de
New email:
PHP Version: OS:


 [2021-05-24 14:57 UTC] info at kgsw dot de
using linux command line, sometimes trailing slash will make sure to identify a directory; 

my own, manual functions would first split path from filename at the _last_ slash;
 which would find NO filename, only path, in that example;

for me unexpected - so need documentation or is a bug? 

I could not find PHP 7.4.3 in the options dropbox to select using:
PHP 7.4.3 (cli) (built: Oct  6 2020 15:47:56) ( NTS )

once reported on Win2k - but discarded as "no URL function" - but I think, this is not the point - it is just unexpected

If you still insist on that IMHO strange behaviour, I would like to add a note to the manual

Test script:
php > var_dump( pathinfo('/home/user/backup.2021-05-24/'));
array(4) {
  string(10) "/home/user"
  string(17) "backup.2021-05-24"
  string(10) "2021-05-24"
  string(6) "backup"

Expected result:
array(4) {
  string(10) "/home/user/backup.2021-05-24"
  // no more set - cause no filename given


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-05-25 12:13 UTC]
-Status: Open +Status: Verified
 [2021-05-25 12:13 UTC]
Well, that behavior might be confusing, but it is long
standing[1], and consistent with basedir() and dirname(), so it
can't be changed. A note in the docs won't hurt.

[1] <>
[2] <>
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Jan 28 04:03:49 2023 UTC