SQL PHP HTML ASP JavaScript articles and free scripts to download
PHP

Curl functions in PHP

WE can collect data from other websites by posting like a browser by using php curl functions. This is not only to collect data but we can also submit form data by POST or GET method. Curl function supports many other protocols. Initially we will start with mostly used HTTP and Post protocols for our scripts and then we will work on others.

Curl support.

We have to first ensure that curl support is available in our server, for this PHP installation is to be checked. The best way is to check is our php info function. Here is a screen shot of php info. php info curl extension support
If curl support is not available then process is same as adding any other features to PHP. Here is one example. Same can be followed to add curl extensions in PHP. Once the curl support is available then we will start with a simple code by getting google.com url. The first line will initialize a curl instance and then we will use

<?php
$my_curl = curl_init();// cURL resource

// WE will add options to our curl
curl_setopt($my_curl, CURLOPT_URL, "http://www.google.com/");
curl_setopt($my_curl, CURLOPT_HEADER, 0);

curl_exec($my_curl); //execute curl function now and display
curl_close($my_curl); // close the curl connection
?>

Reading external url by curl

Be the first to post comment on this article :


Google+
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer