php.net |  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: 2021-07-19 17:44 UTC
Votes:2
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: cmb (profile)
Status: Wont fix Package: Filesystem function related
PHP Version: 5.0.5 OS: WinXP
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: pecoes at gmail dot com
New email:
PHP Version: OS:

 

 [2005-11-02 10:24 UTC] pecoes at gmail dot com
Description:
------------
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-30 23:16 UTC] cmb@php.net
-Package: Feature/Change Request +Package: Filesystem function related
 [2021-07-19 17:44 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-07-19 17:44 UTC] cmb@php.net
> Hope that makes sense to you :0)

No, it does not.  realpath() is supposed to "return the
canonicalized absolute pathname", and the canonical directory
separator on Windows is a backslash.

If you still think this would be a useful feature, please pursue
the RFC process[1].

[1] <https://wiki.php.net/rfc/howto>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC