2015-11-27 54 views
0

所以這裏的其他文件不工作是我的問題:PHP包括比指數

我在XAMPP的htdocs根目錄下的index.php文件。其目的是登錄一個用戶。他loggs在後,他被重定向到遊戲/ index.php文件,在那裏我有兩個包括:

<?php include('/game/components/language_declaration.php'); 
     include('/game/components/currency/userdata_func.php'); 
    ?> 

下面是目錄列表:

index.php (which redirects to index below) 
---/game/index.php (includes work) 
---/game/units.php (the same includes dont work) 
---/game/components/language_declaration.php 
---/game/components/currency/userdata_func.php 

有這個索引鏈接,指向units.php。並且在units.php中也有相同的內容,除了它們不工作的事實。這是我的錯誤:

Warning: include(/game/components/language_declaration.php): failed to open stream: No such file or directory in E:\xampp\htdocs\game\units.php on line 7 

Warning: include(): Failed opening '/game/components/language_declaration.php' for inclusion (include_path='.;\xampp\php\PEAR') in E:\xampp\htdocs\game\units.php on line 7 

Warning: include(/game/components/currency/userdata_func.php): failed to open stream: No such file or directory in E:\xampp\htdocs\game\units.php on line 8 

Warning: include(): Failed opening '/game/components/currency/userdata_func.php' for inclusion (include_path='.;\xampp\php\PEAR') in E:\xampp\htdocs\game\units.php on line 8 

我讀過關於這個問題的約20個職位,每一個建議改變路徑,我試圖加點,斜線等人,甚至定義根目錄。沒有工作。請問你能幫幫我嗎?

+0

不使用'/遊戲'而是'遊戲' – Kenney

+0

@Kenney不工作,甚至沒有__DIR__,試過 –

+0

'include $ _SERVER ['DOCUMENT_RO OT']。'/ game/components/currency/userdata_func.php';'你需要從服務器的根目錄中包含。 – Qirel

回答

0

你的包含語句應該是這樣的:

--- /遊戲/ index.php文件

<?php 
    include('components/language_declaration.php'); 
    include('components/currency/userdata_func.php'); 
?> 

--- /遊戲/ units.php

<?php 
    include('components/language_declaration.php'); 
    include('components/currency/userdata_func.php'); 
?> 
+0

這不起作用,我以前也試過這個。 –