URLConnection of PHP

Does anyone know how to code in PHP to parse html response and also sending a http html request out? just like urlconnection of java. I need to do this using PHP.

also, I have web url that return xml as response and I also need to send request via xml, anyone has any sample to help in my project ?

Thanks in advance.

  • trop

PHP has build-in stream wrappers. Just open a file handle to the URL and read/write ahead.

// read
$response = file_get_contents("http://www.example.com/foo/bar");

// write
$request = "qux";
file_put_contents("http://www.example.com/foo/bar", $request);