PHP致命错误require_once

时间:2013-02-06 02:53:24

标签: php

Hello Guys任何人都可以解释为什么这会发生在我的程序中

当我使用此文件夹结构时

enter image description here

并且database.php中的代码是

<?php require_once("../db_config.php");?>

我收到错误 Fatal error: require_once(): Failed opening required '../db_config.php' (include_path='.;F:\xampp\php\PEAR') in F:\xampp\htdocs\project\database\db_mysql\database.php on line 3'

但是当我移动db_config.php

enter image description here

一切正常。我不明白。任何人都可以解释。我更喜欢使用第一个文件夹结构,因为我将为mssql数据库添加一个新的文件夹db_mssql。

1 个答案:

答案 0 :(得分:3)

<?php require_once("../db_config.php");?>

尝试

<?php require_once("../../db_config.php");?>

更好地使用

require_once($_SERVER['DOCUMENT_ROOT'] . 'directory/directory/file');