include():未能打开流:没有这样的文件或目录
问题描述:
这可能只是一个非常愚蠢的问题,但我真的很沮丧,这不工作。 我有一个主文件(home.php)
其中包含<? include ("/production/fetch_order.php"); ?>
。正如我可以看到我试图从home.php访问文件。该文件命名为fetch_order.php
,位于生产文件夹中。我的路径是正确的,拼写也是绝对正确的。但是我结束了这个错误:include():未能打开流:没有这样的文件或目录
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
答
您使用在该行开始的绝对路径(/
),你需要删除斜杠,这将是一个相对路径,例如:
production/fetch_order.php
当添加一个斜杠时,它从系统的根目录开始,没有它,它会在当前目录中查找。
答
看来,路径不正确,请尝试:
<? include ("production/fetch_order.php"); ?>
答
确保路径如果引用(“/production/fetch_order.php”)提供要么从绝对路径文件系统根目录或作为当前文件的相对路径(home.php
)。
include('production/fetch_order.php');
OR
include(dirname(__FILE__) . '/production/fetch_order.php');
一个经常运行到这个错误,并迅速解决它,请按照下列步骤操作:http://stackoverflow.com/a/36577021/2873507 – 2016-04-12 17:02:02
的可能的复制[失败打开流:没有这样的文件或目录](http://stackoverflow.com/questions/36577020/failed-to-open-stream-no-such-file-or-directory) – 2016-04-30 14:24:15