doufei8250 2012-08-01 18:18
浏览 35

too long

PHP-programmers!

I've got a problem with the Include-function in PHP.

I have a website which contains a left column-bar, and that column contains dynamic content which I get with the Include-function with a relative path, because absolute paths isn't available in the Include-function.

When I navigate to other files in other folders I get the error: include(folder/fileToBeIncluded.php) [function.include]: failed to open stream: No such file or directory in /home/mywebsite/public_html/thissite/folder/subfolder/leftcolumn.php on line 3

How am I going to deal with that? I am totally lost, and I've been searching for Google and StackOverflow for about 10 minutes now.

Thank you!

  • 写回答

2条回答 默认 最新

  • dsp15140275697 2012-08-01 18:20
    关注

    Absolute paths are can be used with the include statement.

    Try:

    include $_SERVER['DOCUMENT_ROOT'] . '/folder/fileToBeIncluded.php';
    // or
    include dirname(__FILE__) . '/../fileToBeIncluded.php'; // relative to the path of the file doing the include
    

    At the very least, you can hardcode the path to be absolutely sure (until you move your site elsewhere):

    include '/home/yoursite/public_html/folder/fileToInclude.php';
    

    Please see include documentation.

    评论

报告相同问题?

悬赏问题

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