且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP包含文件。显示未找到错误文件

更新时间:2021-08-20 09:29:11

您应该更改config.php以使用functions.php的绝对路径。如果你有PHP 5.3或更高版本,那就这样做:

You should change config.php to use an absolute path to functions.php. If you have PHP 5.3 or greater, do it like this:

include(__DIR__.'/functions/functions.php');

如果您仍在使用PHP 5.2(或者,上帝禁止,之前的某些内容),您可以这样做这样:

If you are still using PHP 5.2 (or, god forbid, something earlier), you can do it this way:

$dir = dirname(__FILE__);
include($dir.'/functions/functions.php');

__FILE__魔术常量始终包含当前PHP文件名的值,因此 dirname(__ FILE __) call将为您提供当前脚本的完整文件系统路径。

The __FILE__ magic constant always contains the value of the current PHP file name, so the dirname(__FILE__) call will give you the full filesystem path of the current script.