Jump to content

relative v absolute location


mworkman

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.