-2

我在我的 php 文档中包含一个文件,但在本地端和服务器端它不包括我使用 require 但它也无法正常工作并且屏幕上显示错误.. 我检查了路径 100 次它是正确的。错误是这样的:

Warning: require(../library/config.php) [function.require]: failed to open stream: No such file or directory in /home/logics/public_html/clients/creativecellutions/farnelo/files/header.php on line 3

Warning: require(../library/config.php) [function.require]: failed to open stream: No such file or directory in /home/logics/public_html/clients/creativecellutions/farnelo/files/header.php on line 3

Fatal error: require() [function.require]: Failed opening required '../library/config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/logics/public_html/clients/creativecellutions/farnelo/files/header.php on line 3

请帮我解决这个问题。

这是我的代码:

<?php 
require ("../library/config.php");
require ("../library/functions.php");
?>
4

4 回答 4

0
 require(../library/config.php) 

指向目录中的错误位置。获取 config.php 相对于该脚本正在调用的文件的位置的位置。那应该可以解决错误。

于 2012-11-23T05:49:23.803 回答
0

您的代码将尝试包含位于

/home/logics/public_html/clients/creativecellutions/farnelo/library/config.php

你确定这是文件的当前位置吗?

如果是,那么唯一可能的问题是您没有使用 php 读取文件的权限。

于 2012-11-23T05:57:26.813 回答
0

我猜您没有直接运行clients/creativecellutions/farnelo/files/header.php并将其包含在其他文件index.php或其他文件中,这可能就是问题所在。尝试使用相对路径require_once( dirname(__FILE__) . '/../library/config.php' );

于 2012-11-23T06:00:32.233 回答
0

尝试使用 getcwd() 函数。

那是

include(getcwd()."path to config.php");
于 2012-11-23T06:37:48.823 回答