Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8258823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:40:52+00:00 2026-06-08T02:40:52+00:00

I have simplexml_load_file instruction placed withing included PHP file. But this instruction works depending

  • 0

I have simplexml_load_file instruction placed withing included PHP file. But this instruction works depending on where I include this file from. Why? Is it possible to make relative file path be interpreted relatively to the file instruction placed in?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:40:53+00:00Added an answer on June 8, 2026 at 2:40 am

    You can always access the current file’s full path with the magic __FILE__ constant, so you can write your simplexml_load_file() call like this:

    <?php
    simplexml_load_file(dirname(__FILE__).'/file.xml');
    

    Update

    Since PHP 5.3, there have been a new __DIR__ introduced, you can use it in place of the dirname(__FILE__) like this:

    <?php
    simplexml_load_file(__DIR__).'/file.xml');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml object like this $obj = simplexml_load_file('/path/to/file.xml'); i also create one
I have a PHP script which reads from an xml file to generate a
I have an object returned from $xml = simplexml_load_file($file). I'm trying to access 'location-id'
I have the following code to read in an XML file: $xml2 = simplexml_load_file('http://www.facebook.com/feeds/page.php?format=rss20&id=334704593230758');
I have the following: <?php #Load in File $xmlUrl =http://sports.espn.go.com/espn/rss/mlb/news; $ConvertToXml = simplexml_load_file($xmlUrl); #
I am trying to read this XML file using PHP and I have two
I have loaded an XML file using simplexml_load_file($filePath,'SimpleXMLElement', LIBXML_NOCDATA); And for most of the
I have this simple XML file : <?xml version=1.0 encoding=utf-8 ?> <Artists> <artist artistId=1>
I have an XML file that needs parsing in PHP. I am currenlty using
Within my index.php file I have an AJAX function that will call a function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.