我试图用代码
包含一个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
答案 0 :(得分:1)
include dirname(__FILE__) . '/inc/file.php';
答案 1 :(得分:1)
使用此
include $_SERVER['DOCUMENT_ROOT'].'/inc/file.php';
答案 2 :(得分:0)
set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER[DOCUMENT_ROOT]/inc);
include "$_SERVER[DOCUMENT_ROOT]/inc/file.php";