PHP包括对索引以外的文件不起作用

时间:2015-11-27 22:50:48

标签: php include

所以这是我的问题:

我在xampp的htdocs的根目录中有一个index.php。其目的是登录用户。登录后,他被重定向到game / 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个关于这个问题的帖子,每个人都建议改变路径,我试图添加点,斜杠等,甚至定义根目录。没有用。你能帮帮我吗?

1 个答案:

答案 0 :(得分:0)

您的include语句应如下所示:

<强> --- /游戏/ index.php的

S=substruct('.','data','.','head','{}',{1},'.','data2')
%previous line is the same as: S=struct('type',{'.','.','{}','.'},'subs',{'data','head',{1},'data2'})
f=subsref(class,S)

<强> --- /游戏/ units.php

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