[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

PHP: why do I keep getting an error for the script below?

Hello Experts,

I am trying to open xml file... the file is on the server; but having errors when trying to open via script... pls take a look at the script below...

any ideas why is failing?

thank you experts...

regards
if (file_exists('http://localhost/tests/test.xml')) {
    $xml = simplexml_load_file('http://localhost/tests/test.xml');
    print_r($xml);
} else {
    exit('Failed to open test.xml.');
}

------------- ERROR -------------
Failed to open test.xml

Open in new window

0
epifanio67
Asked:
epifanio67
1 Solution
 
Greg AlexanderLead DeveloperCommented:
I am assuming when you navigate to http://localhost/tests/test.xml, it show the xml file right?
0
 
epifanio67Author Commented:
yeah.. i do..

thank you expert....
0
 
epifanio67Author Commented:
the path was wrong
(file_exists('test.xml'))

thank you
0
 
haloexpertsexchangeCommented:
Make sure that the permissions are right on both the folder and the file itself to all php to open it.
0
 
Lukasz ChmielewskiCommented:
Use this syntax:
if (file_exists($_SERVER['DOCUMENT_ROOT'].'/test/test.xml')) {
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now