0

我试图在代码中包含一个 php 文件

include "$_SERVER[DOCUMENT_ROOT]/inc/file.php";

我得到的错误是

Warning: include() [function include]: unable to access C:/wamp/www/inc/file.php on line 6
Warning include(C:/...... Failed to open stream no error.

我尝试使用 require_once; 错误是一样的,我的 php 版本是 5.2

4

3 回答 3

1
include dirname(__FILE__) . '/inc/file.php';
于 2013-02-22T17:56:11.133 回答
1

用这个

include $_SERVER['DOCUMENT_ROOT'].'/inc/file.php';
于 2013-02-22T17:57:22.053 回答
0
set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER[DOCUMENT_ROOT]/inc);
include "$_SERVER[DOCUMENT_ROOT]/inc/file.php";
于 2013-02-22T18:00:24.040 回答