2015-11-27 28 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

这不起作用,我以前也试过这个。 –