doudang2817 2010-08-23 09:43
浏览 71
已采纳

require_once在没有包含路径的情况下工作

I have file 1.php having a require_once for 2.php (both of them are in different folders). The issue I am having is that 1.php seems to magically include 2.php since the path for 2.php is not in 1.php. Just to be sure, I even added a set_include_path('.') before the require_once '2.php', but it still works... Is there something obvious I am missing or is this plain weird??

Edit:

//-- file 1.php
//-- long list of requires...
set_include_path('.');
echo get_include_path();
require_once '2.php';

The above works fine while 1.php and 2.php are in different folders.

  • 写回答

5条回答 默认 最新

  • douan2478 2010-08-23 10:43
    关注

    There is some include magic in PHP, i've met it before.
    Something autoload related, I believe.
    It always looks in the folder where file with running class resides

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

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?