Search code examples
language-agnostic

Is using the directory separator constant necessary?


I am using PHP, but I guess this question might be language agnostic.

With PHP, a constant is defined by PHP, called DIRECTORY_SEPARATOR. I have seen this in Joomla

define('DS', DIRECTORY_SEPARATOR);

I thought this looked like a good idea so I incorporated it into some of my sites. Now I'm asking myself why. I have only experience on Windows and OS X and from what I know Microsoft, Linux and Apple all use the forward slash as the directory separator.

Is using this constant unnecessary?


Solution

  • Mac OS Classic uses ":", for instance. See Wikipedia for details. Also it's considered good style avoiding 'magic numbers' or similar constructs.