简体   繁体   English

PHP常量问题

[英]PHP Constant Question

What is the 是什么

DIRECTORY_SEPARATOR

constant contain? 常量包含?

I can't find anything on google explaining this but its used in my OOP book. 我在Google上找不到任何能解释这一点的内容,但是在我的OOP书中使用了它。

It is the separator that link folder in a path like "/" in : 它是分隔符,将文件夹链接到类似“ /”的路径中:

here/is/my/path 这里/是/我/路径

The separator depends on which OS you are running your website. 分隔符取决于您正在运行网站的操作系统。

On windows, this is "\\" : 在Windows上,这是“ \\”:

my\\path\\to\\folder 我的\\路径\\到\\文件夹

On Unix it's "/" 在Unix上,它是“ /”

Either '/' or '\\' depending on your OS. '/'或'\\'取决于您的操作系统。 Use it when specifying paths to make code more portable between Unix-y systems and Windows. 在指定路径以使代码在Unix-y系统和Windows之间更易于移植时使用它。

It's sort of on the tin. 有点锡。

When I run 当我跑步

var_dump(DIRECTORY_SEPARATOR);

I get (on my Linux/Ubuntu box) 我得到(在我的Linux / Ubuntu机器上)

string(1) "/" 

(A forward slash). (正斜杠)。 This is the separator string that applies to file paths on the OS your server is running on. 这是适用于运行服务器的OS上文件路径的分隔符字符串。 It will most probably be a \\ (backslash) on Windows systems. 在Windows系统上,很有可能是\\ (反斜杠)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM