|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9780 realpath doesn't return trailing slash
Submitted: 2001-03-16 05:19 UTC Modified: 2001-04-30 01:55 UTC
From: fabiankessler at usa dot net Assigned:
Status: Closed Package: Directory function related
PHP Version: 4.0.4 OS: winnt 4.0
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: fabiankessler at usa dot net
New email:
PHP Version: OS:


 [2001-03-16 05:19 UTC] fabiankessler at usa dot net
echo dirname(realpath("f:/dir 790/asdf/"));

this prints out "f:\dir 790"
and when you do dirname() on this again, well, ...

the problem is that realpath doesn't return the trailing slash so everything else treats asdf as a file



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-04-30 01:55 UTC]
This is not a bug but the behavior of dirname is copied from the UNIX dirname command. The semantics is that it assumes it is getting a path to a file and it strips the first filename and gives you the rest of the path. It doesn't check if the file is really a directory or not. So the following is the behavior:
dirname /tmp/ = /
dirname /tmp/foo.php = /tmp
dirname /tmo/. = /tmp (it assumes . is the filename)

It really has nothing to do with the trailing / of realpath.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Jun 25 08:01:23 2021 UTC