include(): Failed to open stream: No such file or directory

[亡魂溺海] 提交于 2019-12-04 02:59:25

问题


This might just come as a very silly question, but i am really frustrated of this not working. I have a home file (home.php) which has contains <? include ("/production/fetch_order.php"); ?>. As it can be seen i am trying to access a file from home.php. The file is named as fetch_order.php which is in the production folder. My path is correct, the spellings are absolutely correct too. However i end up with this error:

Warning: include(/production/fetch_order.php) [function.include]: 
failed to open stream: No such file or directory in /path/to/home.php on line 119

Warning: include() [function.include]: Failed opening '/production/fetch_order.php'
for inclusion (include_path='.:/path/to/php/php5.3.6/lib/php') in
/path/to/home.php on line 119

回答1:


You are using an absolute path (/) at the start of the line, you need to remove that slash and it would be a relative path, example:

production/fetch_order.php

When adding a slash, it starts at the root directory of your system, without it, it looks in the current directory.




回答2:


Make sure that the path you're referencing ('/production/fetch_order.php') is provided either as an absolute path from the file system root directory or as a relative path from the current file (home.php).

include('production/fetch_order.php');

OR

include(dirname(__FILE__) . '/production/fetch_order.php');



回答3:


Seems that path is not correct, try:

<? include ("production/fetch_order.php"); ?>


来源:https://stackoverflow.com/questions/9557945/include-failed-to-open-stream-no-such-file-or-directory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!