To use DIRECTORY_SEPARATOR or not to use it... :]

Hi guys,

What about DIRECTORY_SEPARATOR under Windows (and XAMPP)? Either I’m missing something or it is NOT working under this combo.

I was using it and as I was told to do so, but changed my approach to use Linux-like slashes (/) as I found out that under Windows and XAMPP, DIRECTORY_SEPARATOR seems to be not working. It is being changed to Windows-like slash (\) and - if I’m not mistaken - this is not acceptable by Windows (XAMPP) version of Apache (strange), because this causes images, CSS files and JS scripts NOT to be loaded.

For example, one of extensions has generated such code for me:


<script type="text/javascript" src="/burdzy/assets/e8a2fa9c\galleria.js"></script>

<script type="text/javascript" src="/burdzy/assets/e8a2fa9c\galleria.classic.js"></script>

Which is wrong and is NOT WORKING under Windows + XAMPP.

Have you noticed something similar?

This whole thing seems to be very strange to me. Slashes (/) which are Linux-like path separators are working under XAMPP + Windows while backslashes (\), which are Windows-like path separators are NOT working.

you call a URL, not a path, so DIRECTORY_SEPARATOR is wrong in this place, it must be always ‘/’

It’s safe to use / under Windows except where you want to explode existing path you’ve got from Windows OS that contains \.

@mbi: Thanks (+1) for pointing me out soooou obvious true! :]

@samdark: Yes, it is safe, with the exception, mbi wrote - that is NOT to mix up path and url.