what is the point of using DIRECTORY_SEPARATOR ove

2019-08-05 18:21发布

Why would I choose to use . DIRECTORY_SEPARATOR . instead of . "/" . ?

My initial thought was that there could be a different separator instead of a slash, but if I'm designing, say, a Wordpress Plugin, can I not assume that there is always a / separating two folders?

1条回答
神经病院院长
2楼-- · 2019-08-05 18:53

If the application is going to run on a variety of operating systems then the directory won't always be a forward slash. It's a backwards slash on Windows for example.

A similar case is new lines. It's \n on *nix, \r\n on Windows, etc. That's why there is PHP_EOL.

查看更多
登录 后发表回答