使用DIRECTORY_SEPARATOR超过“/”的要点是什么在php [英] what is the point of using DIRECTORY_SEPARATOR over "/" in php
问题描述
为什么选择使用。 DIRECTORY_SEPARATOR。
而不是。 /。
?
Why would I choose to use . DIRECTORY_SEPARATOR .
instead of . "/" .
?
我最初的想法是,可能会有一个不同的分隔符而不是斜杠,但是如果我在设计,说,一个Wordpress插件,我不能假设总有一个/分开两个文件夹?
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?
推荐答案
如果应用程序正在要运行在各种操作系统上,那么该目录并不总是正斜杠。例如,Windows是一个向后斜杠。
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.
类似的情况是新行。在Windows上的* nix, \r\\\
上的
\\\
这就是为什么有
PHP_EOL
。
A similar case is new lines. It's \n
on *nix, \r\n
on Windows, etc. That's why there is PHP_EOL
.
这篇关于使用DIRECTORY_SEPARATOR超过“/”的要点是什么在php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!