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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.