Req #35064 [Opn->Wfx]: Adding an optional $directorySeparator parameter to realpath()

From: Date: Mon, 19 Jul 2021 17:44:45 +0000
Subject: Req #35064 [Opn->Wfx]: Adding an optional $directorySeparator parameter to realpath()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235189@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=35064&edit=1 ID: 35064 Updated by: cmb@php.net Reported by: pecoes at gmail dot com Summary: Adding an optional $directorySeparator parameter to realpath() -Status: Open +Status: Wont fix Type: Feature/Change Request Package: Filesystem function related Operating System: WinXP PHP Version: 5.0.5 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > 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> Previous Comments: ------------------------------------------------------------------------ [2005-11-02 10:24:36] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=35064&edit=1

« previous php.bugs (#235189) next »