php中的警告错误

时间:2014-07-30 10:49:25

标签: php include warnings

我开始在一个已经存在一段时间的网站上工作。在我开始之前它会产生以下错误消息:

Warning: main(includes/main_functions.php) [function.main]: failed to open stream: No such file or directory in \\boswinfs01\home\users\web\b748\ez.paphospro\includes\top.php on line 22

Warning: main() [function.include]: Failed opening 'includes/main_functions.php' for inclusion (include_path='.;c:\php\4\pear') in \\boswinfs01\home\users\web\b748\ez.paphospro\includes\top.php on line 22

Warning: main(includes/functions/functions_email.php) [function.main]: failed to open stream: No such file or directory in \\boswinfs01\home\users\web\b748\ez.paphospro\includes\top.php on line 23

Warning: main() [function.include]: Failed opening 'includes/functions/functions_email.php' for inclusion (include_path='.;c:\php\4\pear') in \\boswinfs01\home\users\web\b748\ez.paphospro\includes\top.php on line 23

Fatal error: Call to undefined function: get_includes_file() in \\boswinfs01\home\users\web\b748\ez.paphospro\includes\top.php on line 24

可能是includes \ top.php文件中的路径不正确吗?或者我需要寻找别的东西吗?

top.php文件包含以下代码:     define('BASE_PATH' , '/--/--/--/--/--/--/');(我在这个例子中取出了路径)。

在第22,23,24行,它有以下代码:

 `include("includes/main_functions.php");
  include("includes/functions/functions_email.php");
  include(get_includes_file("includes/config.php"));`

所有上述文件都在这些目录中的服务器上。

我真的需要指出为什么错误存在以及我可以做些什么来解决它们。

感谢您提供任何帮助或建议。

1 个答案:

答案 0 :(得分:0)

警告是由不存在的脚本文件或错误的文件权限引起的。

我建议你做一些重构,用require_once替换include函数。这样你就会得到致命的E_COMPILE_ERROR级错误,这比误导性的应用程序要好。

然后,您必须定义应用程序基本路径define('DOCROOT', realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR);并使用它来引用所有其他应用程序依赖项(例如require_once(DOCROOT.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR.'main_functions.php');