|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #35064 Adding an optional $directorySeparator parameter to realpath()
Submitted: 2005-11-02 10:24 UTC Modified: 2016-12-30 23:16 UTC
Avg. Score:4.0 ± 1.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: pecoes at gmail dot com Assigned:
Status: Open Package: Filesystem function related
PHP Version: 5.0.5 OS: WinXP
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: pecoes at gmail dot com
New email:
PHP Version: OS:


 [2005-11-02 10:24 UTC] pecoes at gmail dot com
Correct me if I'm wrong, but there doesn't seem to be a single PHP-function that requires backslashes in pathnames on a Windows-box. They all work happily with forward slashes. Personally, I have stopped using backslashes altogether, but there's a single function that's always a thorn in my side: realpath(). That frequently leads to ugly work-arounds such as this:

$path = str_replace('\\', '/', realpath($rawpath));

So I'd like to suggest adding an optional $directorySeparator parameter, that would default to the DIRECTORY_SEPARATOR constant:

$path = realpath($rawpath, '/');

(Actually I'd prefer $directorySeparator to default to '/', but letting it default to DIRECTORY_SEPARATOR will cause no incompatibilities with anyone's existing code...)

Hope that makes sense to you :0)

Reproduce code:
see text

Expected result:
see text

Actual result:
see text


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-30 23:16 UTC]
-Package: Feature/Change Request +Package: Filesystem function related
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC