开发者

Loading file from the same directory doesn't work unless I specify the full path

So I have this line of code inside a WordPre开发者_如何学JAVAss plugin. The code file is in the same folder as the XML file I'm trying to load. When I remove the full path and leave just the filename I get an I/O error.

$dom->load("/home/tapadmin/public_html/demo10/wp-content/plugins/".
    "agentmanager/fielddefs.xml");

What's the correct way to load the XML file so I don't have to specify the full path?


The relative paths you specify should be relative to the directory of the originally called PHP file, not the one in which you're doing the include.

So, if a page requests /a/index.php and that includes /a/b/inc.php.inc, a relative path in inc.php.inc will be relative to /a/, not /a/b/.

Consider using dirname(__FILE__) instead to get the directory of the current file.

If the extension properly respects the virtual directory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜