$ _SERVER ['document_root']子域名

时间:2012-02-12 13:32:38

标签: php include document-root

在php文件中我有

include_once($_SERVER['document_root'] .'/path/to/file.php');

当我查看包含例如test.php中的代码的文件时,如果我有这个URL格式,它可以正常工作:

http://www.example.com/path/to/test.php

但如果它是一个子域,就像这样:

http://path.example.com/to/test.php

我收到一条错误消息,指出文件中file.php included的路径不存在。

我已尝试输入完整的网址include_once('http://www.example.com/path/to/file.php');

如何在子域下工作?

1 个答案:

答案 0 :(得分:1)

使用file-systempath。您不能包含其他网址。