Ilia posted two tweaks of cURL and parse_url() available with PHP 5.1.0b3. The first patch allow to add a second parameter to parse_url() so you can specify to return a parameter rather than an array.


$host = parse_url("http://www.ilia.ws/gallery/", PHP_URL_HOST);
echo $host; // will print www.ilia.ws

The cURL improvements, the first one allows the user to retrieve the request sent by cURL to the server

$ch = curl_init($url);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1); // track request information
curl_exec($ch);
curl_getinfo($ch, CURLINFO_HEADER_OUT) // retrieve sent request as a string

The second introduces the convenience function, curl_setopt_array() that allows setting of multiple configuration directives via a single PHP function call. The array of option is based on option name, numeric CURLINFO key and its value.

$ch = curl_init($url);
curl_setopt_array($ch,
array(CURLOPT_RETURNTRANSFER=>1, CURLINFO_HEADER_OUT=>1));