How to manage Directory Separator in PHP?

Status
Not open for further replies.

addisoncave

Active Member
42
2016
1
0
Hi Guys
I use to manage my directory using slash and black slash, but it's quite confusing, because sometimes it's confuse me when i have to use for hyperlinks and windows path. Please let me know if there is an alternative to resolve this confusion.
Sometimes it generate problem when i use backslash between the quotes.
 
2 comments
PHP has a constant that can be used for directories:
Code:
[COLOR=#336699][FONT=&amp]DIRECTORY_SEPARATOR[/FONT][/COLOR]

other than that use for url's just regular "/" slashes.

You can also create your own constant based on that directory seperator, it can be a bit long though:
Code:
[COLOR=#0000BB][FONT=monospace]define[/FONT][/COLOR][COLOR=#007700][FONT=monospace]([/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]'DS'[/FONT][/COLOR][COLOR=#007700][FONT=monospace], [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]DIRECTORY_SEPARATOR[/FONT][/COLOR][COLOR=#007700][FONT=monospace])[/FONT][/COLOR]
 
Last edited:
Hi Guys
I use to manage my directory using slash and black slash, but it's quite confusing, because sometimes it's confuse me when i have to use for hyperlinks and windows path. Please let me know if there is an alternative to resolve this confusion.
Sometimes it generate problem when i use backslash between the quotes.

Code:
[COLOR=#999999]define[/COLOR]([COLOR=#BB8844]'DIR_SEPARATOR'[/COLOR], [COLOR=#BB8844]'/'[/COLOR]); - linux

[COLOR=#999999]define[/COLOR]([COLOR=#BB8844]'DIR_SEPARATOR'[/COLOR], [COLOR=#BB8844]'\\'[/COLOR]); - windows
 
Last edited:
Status
Not open for further replies.
Back
Top