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条)

报告相同问题?

悬赏问题

  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站