Skip to content
WJunction - Webmaster Forum

How to manage Directory Separator in PHP?

Status
Not open for further replies.
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.

About the author

A
Active Member · Joined
42
Messages
1
Reactions
8
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom