【问题标题】:Default directory is www/php and not www in xampp默认目录是 www/php 而不是 xampp 中的 www
【发布时间】:2015-04-01 02:50:31
【问题描述】:

我的 index.html 文件在 c://xampp/htdocs/www

然后我在 c://xampp/htdocs/www/php 中的所有 .php 文件 我在 c://xampp/htdocs/www/images 中的所有图像文件 等等

但出于某种或其他原因,它正在 c://xampp/htdocs/www/php 中寻找 index.html?? 在我的 .php 文件中,当我想包含一个 .php 文件时,我只需要将其引用为

include ('functions.php');

应该是

include ('php/functions.php');

请问如何正确设置我的目录?

【问题讨论】:

    标签: php xampp


    【解决方案1】:

    编辑httpd.conf 文件并将DocumentRoot 行替换为您想要的目录路径。

    【讨论】:

    • 感谢这是我在 httpd.conf DocumentRoot "C:/xampp/htdocs" 中所拥有的
    • 在 httpd-vhost.conf 我有: DocumentRoot "C:/xampp/htdocs/www/"
    • 这些是专门针对 XAMPP 的 .conf 文件吗?
    【解决方案2】:

    使用 包括(“functions.php”)

    因为您在同一个目录中。

    如果你正在使用

    包括('php/functions.php');

    c://xampp/htdocs/www/php/php 中的 PHP 检查文件

    【讨论】:

      【解决方案3】:

      为什么不能使用绝对路径包含文件。我们可以在www/ 目录中创建一个 config.php,您可以在其中定义一个常量,该常量具有您的www/ 的绝对路径。现在您可以在引导程序中加载 config.php 并使用该常量并包含所需的目录文件,如下所示

      config.php
      
      define('ROOT_SYS',dirname(__FILE__).'/'); //$_SERVER["DOCUMENT_ROOT"] for root access
      
      Now in all directory files you can use this to include,
      
      include(ROOT_SYS . 'php/file.php')
      

      【讨论】:

      • 谢谢,但我在 xampp 中的 apache 和我的 .conf 文件必须正确设置。我不想在我的代码中这样做。
      猜你喜欢
      • 2015-04-13
      • 1970-01-01
      • 2014-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多