【问题标题】:XAMPP include_path not workingXAMPP include_path 不起作用
【发布时间】:2018-04-07 01:26:10
【问题描述】:

我试图在我的主 index.php 中要求一些 php 文件,但我收到以下错误:

警告:需要(/opt/lampp/htdocs/steamauth/userinfo.php):未能 打开流:/opt/lampp/htdocs/index.php 中没有这样的文件或目录 在第 4 行

致命错误:require():需要打开失败 '/opt/lampp/htdocs/steamauth/userinfo.php' (include_path='/opt/lampp/htdocs/') 在 /opt/lampp/htdocs/index.php 上 第 4 行

我尝试添加以下代码:

set_include_path('/opt/lampp/htdocs/');
require dirname(__FILE__).'/steamauth/steamauth.php';

我的包含文件 steamauth.php 和 userinfo.php 位于 /opt/lampp/htdocs/steamauth/ 我还尝试在 php.ini 文件中设置 include_path 并将其添加到我的 .htaccess 文件中。是的,我确信这是我想要包含的正确路径。有什么想法吗?

【问题讨论】:

  • 您是否已经尝试重新启动服务器?我使用 XAMPP 遇到了这个问题。我编辑了 PHP.ini 文件,但它不起作用。当我重新启动 XAMPP 控制面板时,它运行良好,没有任何修改。

标签: php server xampp include-path lampp


【解决方案1】:

您的项目文件夹结构是什么?简单地说,尝试从 index.php 获取路径。

// /root/fooDir/userinfo.php
// /root/barDir/index.php

//in index.php
$dir = __DIR__ . '/../fooDir/userinfo.php';

【讨论】:

  • 似乎没有任何效果。我认为这是 php.ini 中的 include_path 的一些问题,但更改它并没有解决问题。如何更改默认的 XAMPP include_path 变量?
【解决方案2】:

我在尝试将新目录添加到 php 路径时遇到了同样的问题。我解决了它在 php.ini 文件中的 include_path 周围添加 双引号。 像这样的:

include_path="C:\xampp\php\PEAR;c:\xampp\smarty\smarty-3.1.30\libs";

【讨论】:

  • 这里用单引号。也许您可能需要编辑您的代码
猜你喜欢
  • 2015-10-08
  • 1970-01-01
  • 2013-09-29
  • 2018-04-24
  • 2015-01-05
  • 2017-11-26
  • 2014-09-25
  • 2018-08-19
  • 2018-09-06
相关资源
最近更新 更多