phpmyadmin 无法使用include打开流

wrrgggsh  于 5个月前  发布在  PHP
关注(0)|答案(1)|浏览(88)

这是一个简单的问题,已经在堆栈溢出,但我尝试了所有可能的答案,它仍然没有固定。
我需要包括配置文件,这是在资产文件夹。我尝试了以下代码:

include_once '../config.php' ;

字符串
我得到这样的错误:

Warning: include(assets/config.php): failed to open stream: No such file or directory in E:\xampp\htdocs\project\assets\handler\ContactHandler.php on line 4

Warning: include(): Failed opening 'assets/config.php' for inclusion (include_path='E:\xampp\php\PEAR') in E:\xampp\htdocs\project\assets\handler\ContactHandler.php on line 4


请给我一个可能的方法,包括在ContactHandler.php配置文件
ContachHandler.php

<?php

include_once 'E:\xampp\htdocs\project\assets\config.php';

echo "ddddd";
exit;
 include (CONTROLLER.'ContactController.php');
$form = $_POST['form'];
$cnt_controller = new ContactController();
switch ($form)

{

    case 'AddContact':
        $cnt_controller->AddContact($_POST);
        break;
    case 'ContactUs':
    $cnt_controller->ContactUs($_POST);
        break;

}


?>

vs91vp4v

vs91vp4v1#

检查您的包含路径是否更改,并检查文件/文件夹权限。
试试这个代码:

<?php
$config_path = '../config.php' ;
if (file_exists($config_path)){
    require_once $config_path;
}
else {
    $config_path = 'config.php';
    if (file_exists($config_path)) {
        require_once $config_path;
    }
    else {
        $config_path = '../../config.php';
        require_once $config_path;
    }
}

echo "ddddd";
echo $config_path;
exit;
?>

字符串
对于测试集静态路径:

include_once 'E:\xampp\htdocs\project\assets\config.php';


希望这对你有帮助!

相关问题