mworkman Posted November 15, 2010 Share Posted November 15, 2010 I am trying to load an xml file but I can't seem to find the location to load it. Here is the location of the xml file: C:\inetpub\wwwroot\php\webphp.xml Here is the location of the file trying to load the xml: C:\inetpub\wwwroot\php\gui\guiindex.php What location would I put in here: $xml = new SimpleXMLElement("XMLFILELOCATION", NULL, true); Link to comment https://forums.phpfreaks.com/topic/218772-relative-v-absolute-location/ Share on other sites More sharing options...
simshaun Posted November 15, 2010 Share Posted November 15, 2010 Have you tried C:\inetpub\wwwroot\php\webphp.xml? If so, did you escape the backslashes (assuming you surrounded the string with double-quotes?) Alternatively, ../webphp.xml Link to comment https://forums.phpfreaks.com/topic/218772-relative-v-absolute-location/#findComment-1134649 Share on other sites More sharing options...
rwwd Posted November 15, 2010 Share Posted November 15, 2010 well firstly you need to define the absolute file path, and have that done in the root file, something like this:- define('ABSOLUTE_PATH', dirname(__FILE__). "/"); This will give you the complete server path for you to work with defined within a constant - and a trailing slash, then you can refer to this in the xml function - this should help you out with this issue, but seriously, always use absolute paths, then you can avoid the toothpick syndrome, and this will make your code easier to maintain. Rw Link to comment https://forums.phpfreaks.com/topic/218772-relative-v-absolute-location/#findComment-1134680 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.