[英]PHP Include Path Not Found
I'm facing a problem when I'm trying to include a certain file. 尝试包含特定文件时遇到问题。 When I try to load the file I face this error :
当我尝试加载文件时,我遇到此错误:
failed to open stream: No such file or directory in ...
On the other hand , a <a href="/wT/sys/background.php">background</a>
sends me directly to the file I want to include ( not the source code of it , but the output) 另一方面,
<a href="/wT/sys/background.php">background</a>
将我直接发送到我要包含的文件中(不是它的源代码,而是输出)
How come the include function cannot access the file via the given path but I can access it using a href ? 为什么include函数不能通过给定的路径访问文件,但是我可以使用href来访问它呢? *I need to get the source code of the file , not only the output , otherwise I'd just include the http://.... path *I run the php code on localhost, if it matters
*我需要获取文件的源代码,而不仅仅是输出,否则我将仅包含http:// ....路径*如果重要,我会在localhost上运行php代码
I also tried to chechk whether I need to reconfigure the php.ini file but I didn't find anything useful ( Include url is allowed altough , as I said , I don't need to use it) 我还尝试检查是否需要重新配置php.ini文件,但没有发现任何有用的方法(如我所说,允许Include url是完全允许的,我不需要使用它)
Any suggestion would be helpful, Thanks in advance 任何建议都会有所帮助,在此先感谢
include $_SERVER['DOCUMENT_ROOT'] . '/wT/sys/background.php';
If file you want to include is in the lower directory as the script into which you are trying to include it, then try: 如果要包括的文件位于要包含在其中的脚本的较低目录中,请尝试:
include __DIR__.'/wT/sys/background.php';
or simply 或简单地
include 'wT/sys/background.php';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.