views:

23

answers:

1

So I have this line of code inside a WordPress 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?

+6  A: 

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.

Artefacto
that did the trick, thanks.
Jason Miesionczek