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: 2016-12-30 23:16 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:
Status: Open Package: Filesystem function related
PHP Version: 5.0.5 OS: WinXP
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

History

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