-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed as not planned
Description
Description
I really miss in PHP a function to join easily paths like the node's path.join or in other languages.
I know it's really easy to implement in the user-land, but It would be nice to have this PHP as this is some base filesystem functionality like realpath
, basename
which should be included by default (in my opinion).
Usage would be like:
path_join('/base', 'my', 'path'); // /base/my/path
path_join('/base', 'my', 'path', 'test', '..'); // /base/my/path
Why not just string concatenation?
When you concat just the paths you have to think about:
- does the before path end with a
/
, you have to normalize all parts - for windows compatibility you have to use
DIRECTORY_SEPERATOR
aragon999, andreaskienast, bojanrajh, AydinHassan, Christian-Rades and 8 moreleichteckig, matheusgontijo and kristoffermodified