|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #10916 OS-independent path parsing
Submitted: 2001-05-16 23:37 UTC Modified: 2016-08-06 04:34 UTC
Avg. Score:3.2 ± 1.5
Reproduced:2 of 3 (66.7%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: mark at arcabama dot com Assigned:
Status: Wont fix Package: Filesystem function related
PHP Version: * OS: *
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: mark at arcabama dot com
New email:
PHP Version: OS:


 [2001-05-16 23:37 UTC] 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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-17 12:31 UTC]
-Summary: (Feature Request) OS-independent path parsing +Summary: OS-independent path parsing -Package: Feature/Change Request +Package: Filesystem function related -Operating System: Linux 2.2.18 +Operating System: * -PHP Version: 4.0.4pl1 +PHP Version: *
 [2012-02-29 09:23 UTC] johnnybifter at gmail dot com
I doubt this will ever appear in the language as it sounds more like a library 
try using this for the OS-independent path parsing
    explode(DIRECTORY_SEPARATOR, $path);
 [2016-08-06 04:34 UTC]
-Status: Open +Status: Wont fix
 [2016-08-06 04:34 UTC]
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:


realpath() might also provide useful, as it normalizes a path to the OS path, meaning that:

Will convert into (on Windows):

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
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 07:01:27 2024 UTC