require_once :failed to open stream: no such file or directory

前端 未结 5 624
孤独总比滥情好
孤独总比滥情好 2020-12-01 12:50

I have this testing code in \"PAGE A\":

         


        
相关标签:
5条回答
  • 2020-12-01 13:17

    set_include_path(get_include_path() . $_SERVER["DOCUMENT_ROOT"] . "/mysite/php/includes/");

    Also this can help.See set_include_path()

    0 讨论(0)
  • 2020-12-01 13:19

    It says that the file C:\wamp\www\mysite\php\includes\dbconn.inc doesn't exist, so the error is, you're missing the file.

    0 讨论(0)
  • 2020-12-01 13:28

    You will need to link to the file relative to the file that includes eventManager.php (Page A)

    Change your code from
    require_once('../includes/dbconn.inc');

    To
    require_once('../mysite/php/includes/dbconn.inc');

    0 讨论(0)
  • 2020-12-01 13:33

    this will work as well

     require_once(realpath($_SERVER["DOCUMENT_ROOT"]) .'/mysite/php/includes/dbconn.inc');
    
    0 讨论(0)
  • 2020-12-01 13:34

    The error pretty much explains what the problem is: you are trying to include a file that is not there.

    Try to use the full path to the file, using realpath(), and use dirname(__FILE__) to get your current directory:

    require_once(realpath(dirname(__FILE__) . '/../includes/dbconn.inc'));
    
    0 讨论(0)
提交回复
热议问题