How to send a GET request from PHP?

Veera picture Veera · Jun 6, 2009 · Viewed 552.5k times · Source

I'm planning to use PHP for a simple requirement. I need to download a XML content from a URL, for which I need to send HTTP GET request to that URL.

How do I do it in PHP?

Answer

Sasha Chedygov picture Sasha Chedygov · Jun 6, 2009

Unless you need more than just the contents of the file, you could use file_get_contents.

$xml = file_get_contents("http://www.example.com/file.xml");

For anything more complex, I'd use cURL.