I would like to discuss this issue. Who does not know, this is such a thing that takes into account in the paths to the files slash depending on the OS. But I somehow do not really understand why bother with this, if php seems to be perfectly understandable under Windows where the file is without this whistle. More precisely, I tried and no problems.

  • 2
    the paths with <b> / </ b> work normally both under the line and under Windows, so it’s already not relevant ... And did you try it yourself, torment vague doubts? :) - Zowie
  • No, people here simply criticized my system, I am already writing strictly under 5.3, I have a look at 5.4. For now it is written I use the first version. Well, that's not the hunt to mess around. Although many further continue to poke a finger. - Arni
  • AlexWindHope is very right! the path is the path and how it is this or that php or asp or ... the script does not care about the fullness! - Palmervan
  • In this case, all who will poke a finger will send here. You will explain to them :) - Arni
  • It is really difficult to imagine any new OS, in which the separator will be different from '/'. In fact, Winda gave up, the API via .dll supports '/'. So, build yourself on health, the path through '/'. - avp

1 answer 1

I happened to pass by after 4 years ...

Yes, DIRECTORY_SEPARATOR is still needed . Suddenly you will need part of the file path. How do you get it?

explode(DIRECTORY_SEPARATOR, realpath(__FILE__)). 

Because

 explode("/", realpath(__FILE__)) 
  • Windows does not work as it should. (Yes, yes, I know about pathinfo () )

I also think for many systems the isWindows () function is needed, it can be written like this:

 function isWindows() { return DIRECTORY_SEPARATOR === "\\"; }