phpmyadmin 无法使用include打开流

wrrgggsh  于 2024-01-09  发布在  PHP
关注(0)|答案(1)|浏览(392)

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

  1. include_once '../config.php' ;

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

  1. 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
  2. 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

  1. <?php
  2. include_once 'E:\xampp\htdocs\project\assets\config.php';
  3. echo "ddddd";
  4. exit;
  5. include (CONTROLLER.'ContactController.php');
  6. $form = $_POST['form'];
  7. $cnt_controller = new ContactController();
  8. switch ($form)
  9. {
  10. case 'AddContact':
  11. $cnt_controller->AddContact($_POST);
  12. break;
  13. case 'ContactUs':
  14. $cnt_controller->ContactUs($_POST);
  15. break;
  16. }
  17. ?>

vs91vp4v

vs91vp4v1#

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

  1. <?php
  2. $config_path = '../config.php' ;
  3. if (file_exists($config_path)){
  4. require_once $config_path;
  5. }
  6. else {
  7. $config_path = 'config.php';
  8. if (file_exists($config_path)) {
  9. require_once $config_path;
  10. }
  11. else {
  12. $config_path = '../../config.php';
  13. require_once $config_path;
  14. }
  15. }
  16. echo "ddddd";
  17. echo $config_path;
  18. exit;
  19. ?>

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

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


希望这对你有帮助!

展开查看全部

相关问题