« PHP 5.1 beta 3 PDO notes | Main | Missing XML Features in PHP? »

cURL and parse_url() tweaks

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));

Bookmark this article at these sites
Post a comment





(Email will remain hidden)





Please enter the security code you see here




Related entries
Email to a friend
Email this article to:


Your email address:


Message (optional):