what is the difference between `/` and `\` in php

前端 未结 4 1958
青春惊慌失措
青春惊慌失措 2020-12-18 13:46

I am trying to understand examples in PSR-0, but to no avail. I know that \\ is directory separator (at least in my windows OS), and in my humble opinion, it ca

4条回答
  •  一整个雨季
    2020-12-18 14:26

    \ is used for namespacing whereas / is a path separator on windows filesystem eg C:/Users/Sam/Documents

    What the PSR class loaders allow you to do is, to find and load classes from directories using the information you provide in the namespace.

    For example, a class called response.php can be placed inside folder samayo/http in the root directory of your projects and the full path would be samayo/http/response.php now, PSR allows you to use a namespace samayo\http\reponse to load the file using DIRECTORY_SEPARATOR by changing the directory separators and a little more behind the scene

提交回复
热议问题