Req #10916 [Opn->Wfx]: OS-independent path parsing
| From: | kalle@php.net | Date: | Sat, 06 Aug 2016 04:34:40 +0000 |
| Subject: | Req #10916 [Opn->Wfx]: OS-independent path parsing | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202989@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=10916&edit=1
ID: 10916
Updated by: kalle@php.net
Reported by: mark at arcabama dot com
Summary: OS-independent path parsing
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Filesystem function related
Operating System: *
PHP Version: *
Block user comment: N
Private report: N
New Comment:
Agreed, this sounds more like a library function that is better suited to be implemented in userland
code.
We do have some cross OS compatible constants to help on that part:
DIRECTORY_SEPARATOR
PATH_SEPARATOR
PHP_SHLIB_SUFFIX
realpath() might also provide useful, as it normalizes a path to the OS path, meaning that:
realpath('/windows/system32')
Will convert into (on Windows):
%SystemDrive%\Windows\System32
And parse like that, second alternative we have is pathinfo() which does not validate the actual
path but just parses it and works on any OS path, even mixes afair
Previous Comments:
------------------------------------------------------------------------
[2012-02-29 09:23:15] johnnybifter at gmail dot com
I doubt this will ever appear in the language as it sounds more like a library
function.
try using this for the OS-independent path parsing
explode(DIRECTORY_SEPARATOR, $path);
------------------------------------------------------------------------
[2001-05-16 23:37:37] mark at arcabama dot com
I've looked for something like this in the existing function suite but haven't found it...
Because Windoze and Linux (at least) use different characters to separate elements of a file path, I
think a function that parses a path into an array of subdirectories, basename and extension would be
useful.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=10916&edit=1