Search

Showing posts with label php function. Show all posts
Showing posts with label php function. Show all posts

Saturday, October 11, 2008

CURL and Proxy Support

CURL has support for proxies, including SSL. Below we refer to the code snippet in the first example, but modify it to use a proxy.

[php] // Initialize the CURL library
$cURL = curl_init();

// Set the URL to execute
curl_setopt($cURL, CURLOPT_URL, "http://www.google.com");

// Set options
curl_setopt($cURL, CURLOPT_HEADER, 1);
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cCURL, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($cCURL, CURLOPT_PROXY, "myproxy.com:1080");
curl_setopt($cCURL, CURLOPT_PROXYUSERPWD, "mysuername:mypassword");

// Execute, saving results in a variable
$strPage = curl_exec($cURL);

// Close CURL resource
curl_close($cURL);

// This will print out the HTML contents
echo($strPage);
?>[/php]


source : http://www.codeandcoffee.com

Friday, September 5, 2008

join

join function is easy to use concate string from array.

example

<php
$array = array('lastname', 'email', 'phone');
$comma_separated = join(",", $array);

echo
$comma_separated; // lastname,email,phone

?>


(php4, php5);