Directory separators and cross platform compatibility

I was curious about the impact of the directory separator and how that affects cross platform compatibilitye ver since I started developing on my Vista machine.

I've noticed how different they are compared to the Linux variety. Here's an example:

File path on *nix:

/path/to/file

File path on Windows:

C:\\path\to\file

As you can see the separator is a slash, either a "/" or "" depending on the OS. Why does this matter? Because if we're dealing with files on the server, and the path is going to be recorded so they can be displayed on the Internet, through a URI, than this is going to introduce compatibility issues if not handled correctly. Sigh..

I've seen open source programs handle this type of issue through concatenation. For example the code:

This is probably one of the most misunderstood features in PHP. You don’t use DIRECTORY_SEPARATOR to create paths—you use it to parse/explode/etc. paths given by PHP (the document root, php ini path, etc.). If you want to create a path, just use the forward slash.