When running under Linux or MacOS, PHP only allows /
as a directory separator.
When running under Windows, PHP accepts either /
or
as a directory separator; it treats them exactly the same.
In virtually all cases, it is better to always use /
, because that will allow your code to run on any platform. If you use
for directory separators, then your code will only work on Windows.
The difference on Windows is to allow compatibility with other software that might provide paths with
separators, but unless you specifically need to do that, it's best to stick with /
.
Also, there is another use of
in PHP which might be confusing you (particularly as you mentioned PSR0). The
is also the separator for PHP namespaces.
Namespaces are not the same as directory separators, but they can end up looking like them, because common practice is to organise a project such that the namespaces match the directory structure. This is done to make your code modules easy to find and easy to write an autoloader for them, and it is thus the recommended way of structuring a project as per PSR0, but it is not compulsory in the PHP language; namespaces are not the same as directory paths.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…