嗨,我有以下目錄結構:PHP語法錯誤問題
Main Folder -> Classes -> user_classes
都互相嵌套。我有內部類目錄下面的文件
always_include_top.php
custom_error_handler.php
config.php
database.php
外面的database.php中文件如下:
<?php
include_once("always_include_top.php");
include_once("config.php");
include_once("custom_error_handler.php");
include_once ("user_classes/newDatabase.php");
class Database extends newDatabase
{
// some more code... with extra functions
public function dbBackUp($backupfile = NULL)
{
//code...
}
}
?>
我在用戶user_classes目錄下面的文件
newDatabase.php
此文件的代碼示例是
<?php
include_once("../always_include_top.php");
include_once("../config.php");
include_once("../custom_error_handler.php");
error_reporting(E_ALL);
class newDatabase
{
// my code goes here
}
?>
爲什麼我會收到以下錯誤類/ database.php中(沒有在類錯誤/ user_classes/newDatabase.php)
Warning: include_once(../always_include_top.php) [function.include-once]: failed to open stream: No such file or directory in E:\wamp\www\greeting_cards\adm\classes\user_classes\database.php on line 2
Warning: include_once() [function.include]: Failed opening '../always_include_top.php' for inclusion (include_path='.;C:\php\pear') in E:\wamp\www\greeting_cards\adm\classes\user_classes\database.php on line 2
Warning: include_once(../config.php) [function.include-once]: failed to open stream: No such file or directory in E:\wamp\www\greeting_cards\adm\classes\user_classes\database.php on line 4
Warning: include_once() [function.include]: Failed opening '../config.php' for inclusion (include_path='.;C:\php\pear') in E:\wamp\www\greeting_cards\adm\classes\user_classes\database.php on line 4
Warning: include_once(../custom_error_handler.php) [function.include-once]: failed to open stream: No such file or directory in E:\wamp\www\greeting_cards\adm\classes\user_classes\database.php on line 5
Warning: include_once() [function.include]: Failed opening '../custom_error_handler.php' for inclusion (include_path='.;C:\php\pear') in E:\wamp\www\greeting_cards\adm\classes\user_classes\database.php on line 5
Fatal error: Cannot redeclare class Database in E:\wamp\www\greeting_cards\adm\classes\database.php on line 12
我想這兩個文件單獨編譯。因爲我會根據頁面類型將文件包含在其他文件中。這裏包括什麼問題?
你在'user_classes/newDatabase.php'中有什麼? – MGwynne
@MGwynne我已經把它放在「*我在用戶user_classes目錄中有以下文件*」部分。看看 – footy
我想你可以將'include_once()'database.php中的路徑更改爲'include_once(「classes/always_include_top.php」);' – jeni