Require_once PHP Error

后端 未结 4 1521
闹比i
闹比i 2021-01-17 19:09

I\'ve been programming in PHP for several years now and never encountered this error before.

Here\'s my widget.php file:

re         


        
相关标签:
4条回答
  • 2021-01-17 19:34

    I know the question is old, but it is still relevant.

    In my experience, the "open_basedir" directive is most likely to cause this issue.

    0 讨论(0)
  • 2021-01-17 19:43

    Remember that in the second case, you're specifying a path, but in the first case it uses your includes path. Perhaps rather than explicitly specifying .. in the second case, you case modify your include path.

    http://php.net/manual/en/function.set-include-path.php

    0 讨论(0)
  • 2021-01-17 19:57

    Maybe you are in the wrong work directory. Its a bad idea to rely on it (except you explictly want to access it) anyway. Use

    require __DIR__ . '/../fruit.php';
    

    or with pre-5.3

    require dirname(__FILE__) . '/../fruit.php';
    

    Remind, that paths starting with .., or . are not resolved against the include-path, but only against the current work directory.

    0 讨论(0)
  • 2021-01-17 20:01
    require_once('fruit.php');
    

    This searches for fruit.php in the same directory as widget.php is in, no matter what the current working directory is.

    require_once('../fruit.php');
    

    This searches for fruit.php in a directory above the current directory, not in the directory above the one widget.php is in.

    0 讨论(0)
提交回复
热议问题