what is the point of using DIRECTORY_SEPARATOR over “/” in php

混江龙づ霸主 提交于 2019-12-11 08:52:00

问题


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:


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.



来源:https://stackoverflow.com/questions/15047516/what-is-the-point-of-using-directory-separator-over-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!