dongzhiju0324 2018-11-20 15:03
浏览 85
已采纳

无法包含其他文件夹中的文件

I have current directory structure htdocs/mvc2/ which includes app and public folders.

If i run bootstrap.php http://localhost/mvc2/app/core/bootstrap.php with require_once '../config/config.php' it's included, works fine.

If i try to include bootstrap.php in my http://localhost/mvc2/public/index.php I'm getting the following errors:

Warning: require_once(../config/config.php): failed to open stream: No such file or directory in C:\xampp\htdocs\mvc2\app\core\bootstrap.php on line 2

Fatal error: require_once(): Failed opening required '../config/config.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\mvc2\app\core\bootstrap.php on line 2

I can include bootstrap.php file in my index.php if i comment out all the includes in bootstrap.php file though:|.

Im using windows7 with xampp. I have tried changing php.ini file as suggested by others having the same problem to no avail. It's currently:

; UNIX: "/path1:/path2"
include_path=C:\xampp\php\PEAR
; Windows: "\path1;\path2"
;include_path = ".;C:\xampp\php\pear"
  • 写回答

2条回答 默认 最新

  • douh9817 2018-11-20 15:21
    关注

    open

    C:\xampp\htdocs\mvc2\app\core\bootstrap.php

    and edit this line

    require_once('../config/config.php')
    

    give the full path of this file config.php

    you can use $_SERVER['DOCUMENT_ROOT'].'/YOUR_INCLUDEABLE_FILE_NAME';

    $_SERVER['DOCUMENT_ROOT'] is The document root directory under which the current script is executing, as defined in the server's configuration file.

    your server will return C:\xampp\htdocs by using $_SERVER['DOCUMENT_ROOT'].

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 两个不同Subnet的点对点连接
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)
  • ¥66 比特币地址如何生成taproot地址