开发者

Fatal error: require_once() [function.require]: Failed opening required

开发者 https://www.devze.com 2023-02-25 18:29 出处:网络
I am working in php project, its giving the error as: Warning: require_once(ROOT_PATH/lib/confs/Conf.php) [function.require-once]: failed to open stream: No such file or directory in ..\\htdocs\\G

I am working in php project, its giving the error as:

Warning:

require_once(ROOT_PATH/lib/confs/Conf.php) [function.require-once]: failed to open stream: No such file or directory in ..\htdocs\GProject\lib\exception\ExceptionHandler.php on line 20

开发者_JS百科

Fatal error: require_once() [function.require]: Failed opening required 'ROOT_PATH/lib/confs/Conf.php' (include_path='.;C:\php5\pear') in ..\htdocs\GProject\lib\exception\ExceptionHandler.php on line 20

But in \ExceptionHandler.php file, the 20th line is

require_once ROOT_PATH . '/lib/confs/Conf.php';

And I have the file Conf.php under the lib/confs/Conf.php itself, even though I am getting the error.

What may be the problem. Thanks in advance.


I would go through the following assumptions debugging this,

  1. The file doesn't exist.
  2. The ROOT_PATH is incorrectly set.
  3. The current working directory isn't what is expected, so if ROOT_PATH is relative, it's breaking the full path.

If none of the above is the case, I'm not sure.

Some libraries must be installed into a directory that is listed in PHP's library path. In these situations you have a few options:

  • Install the library into a directory searched by PHP by default (e.g., /usr/share/php).
  • Update the include path using set_include_path without overwriting the old path (use get_include_path in combination with PATH_SEPARATOR).


ROOT_PATH is not defined in your script. This should be a defined constant with the value of your root path.

Check it if it is defined or not.

if (defined('ROOT_PATH')) { echo 'Defined';} else { echo 'Not defined'; }

It is not defined.

If it was defined then your error message will contain the value of defined constant since it contains the constant itself in error.

Define in your script.

define('ROOT_PATH',$_SERVER['DOCUMENT_ROOT']); //an example

OR you have forgot to include the configuration file in which these constant are defined.


Just do an echo of the whole path you pass to the require_once function and carefully check if there is something wrong with it :

echo ROOT_PATH . "/lib/confs/Conf.php";


I ran into this problem today. I found the answer. PHP Bug #23392

Basically you have to install the Pear OLE extension.

pear install OLE

0

精彩评论

暂无评论...
验证码 换一张
取 消