我试图在/html/目录的开头包含一个文件(/wp-load.php)。我试图从/wp-content/themes/pw-steel-orange/index-load.php,中包含它,但我总是收到错误消息
警告: /nfs/c07/h01/mnt/102799/domains/platyworld.com/html/wp-content/themes/pw-steel-orange/index-load.php (../wp-load.php)require_once函数.require_once on :未能打开流:第1行的require_once中没有这样的文件或目录 致命错误:(include_path='.:/usr/local/php-5.2.6-1/share/pear') () function.require:打开失败需要'../wp-load.php‘/nfs/c07/h01/mnt/102799/domains/platyworld.com/html/wp-content/themes/pw-steel-orange/index-load.php中的第1行
我做错了什么吗?我想../把包含带到开头目录
抱歉,如果这是一个副本,我在我的搜索中找不到与此相关的东西.
发布于 2010-08-07 01:49:51
您可以发出以下命令,查看从何处提取文件(您所在的位置):
// get your current working directory
echo getcwd();然后相应地包括该文件。
// file is 3 dirs back
include '../../../wp-load.php';例如,如果您正在使用像CodeIgniter这样的框架,那么在应用程序开始时就会有一个调用所有其他代码的index.php文件。所以你必须根据那个文件包括那个文件。
大多数框架都使用他们称为BASEPATH的东西,即当前站点的实际完整服务器路径。当您将站点迁移到另一个目的地时,这可能是非常有用的。
发布于 2010-12-26 22:43:55
这是一种半自动的方法:
$incPath = str_replace("/wp-content/plugins/PLUGIN_NAME","",getcwd());
ini_set('include_path', $incPath);
include('wp-load.php');尽管如此,它仍然是一个包含wp-load.php的坏主意。(如果删除此链接,看这里的那一页 )
https://stackoverflow.com/questions/3428837
复制相似问题