PHP-使用require_once/include/require,路径相对于什么? [英] PHP - with require_once/include/require, the path is relative to what?
本文介绍了PHP-使用require_once/include/require,路径相对于什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在"index.php"
上时,我会执行require_once("/all_fns.php")
.
"all_fns.php"
本身要求文件具有相对于all_fns.php
的路径(本身).
"all_fns.php"
itself requires files with paths relative to all_fns.php
(itself).
我的问题是,我应该在all_fns上相对于all_fns.php或index.php的路径上写路径吗?
My question is, should I write the paths on all_fns relative to all_fns.php or to index.php?
这一切都让我感到困惑,并想弄清楚它.
This is all very confusing to me and wanted to get it straight.
推荐答案
它们被视为相对于index.php
的.
如果您需要引用与包含相关的文件,请使用
If you need to reference a file relative to the include, use
__DIR__."/relative/file.php";
这篇关于PHP-使用require_once/include/require,路径相对于什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文