1

我在远程服务器上包含文件时遇到问题(但在我的本地 Windows PHP+Apache 配置上它工作正常......)。

当我尝试从包含的文件中包含文件时会出现问题,如下所示:

index.php 的内容:

<?php

include("Dir1/File1.php");

?>

Dir1/File1.php 的内容:

<?php

include("File2.php");
include("File3.php");

echo("<p>File1 include done.</p>");

?>

Dir1/File2.php 的内容

<?php
echo("<p>File2 include done.</p>");
?>

Dir1/File3.php 的内容

<?php
echo("<p>File3 include done.</p>");
?>

File2.php 和 File3.php 没有得到评估,但是当我将例如 File2.php 更改为 File99.php (一些不存在的文件)时,我收到文件不存在的标准警告。

但是当我更改 Dir1/File1.php 的内容以包含这样的文件时:

<?php

include("Dir1/File2.php");
include("Dir1/File3.php");

echo("<p>File1 include done.</p>");

?>

然后对文件进行评估...

4

3 回答 3

1

sounds like you don't have "." (current folder) in your include path. You should modify your php.ini file to add it. You can find out the value on your live and test server by doing

<?php
phpinfo();
?>
于 2010-03-11T00:26:06.890 回答
0

尝试使用完整路径包含:

include(dirname(__FILE__) . "/Dir1/File3.php");
于 2010-03-11T00:27:32.147 回答
0

这对我来说每次都有效:

<?php require_once($_SERVER['DOCUMENT_ROOT'] . '/path/to/File3.php'); ?>
于 2011-04-22T16:36:50.357 回答