1

I need to read a file on a foreign server.

Apart from cURL and file_get_contents() are there any other ways to read the file using PHP?

This needs to be deployed on a variety of servers and some servers we are deploying to are really cheap shared hosts. These often have configurations that disable either or both of these methods.

The file I need to get is an XML file if that makes any difference.

2 Answers 2

2

If the target is an XML file, you could try using PHP's DOM implementation. For example:

<?php
$doc = new DOMDocument();
$doc->load('http://www.w3schools.com/xml/guestbook.asp');
header("Content-type: text/xml");
echo $doc->saveXML();
?>
Sign up to request clarification or add additional context in comments.

Comments

1

You can always use a raw socket http://php.net/manual/en/book.sockets.php

or call out to the shell and use curl or wget from there

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.