PHP CURL-The powerful and useful library to fetch contents from websites remotely.Using Php CURL you can able to download the webpage source of any website and store it to a php variable.Curl requests to any webpage server and downloads the content.
See The rest of PHP beginner tutorials
- Array functions you should know in PHP
- 5 Useful mathematical functions in PHP
- How to :Encrypt password in PHP
- How to:Find duplicate words in a string using PHP
- Initialize Curl
- Set Curl Options
- Execute Curl
- Close curl
< ? $ch = curl_init(); // Initialize Curl $url="http://devlup.com"; //URL of the webpage you want to download curl_setopt($ch, CURLOPT_URL, $url); // Set CURL options curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); //Return the handle if the curl session is set $output = curl_exec($ch); // execute the curl curl_close($ch); // close the curl ?>
In this way you can download the source page of the url to $output variable.There are many curl options (curl_setopt) that can be used according to your applications.See the list of curl options.
Many php programmers use file_get_contents() function to download content from websites but this has the limitation, you cannot download webpages that uses secure urls (https://).The other disadvantage of file_get_contents() is slower performance when compared to Curl.
Read our basic PHP tutorials to get started in PHP programming.If you need clarification regarding php CURL ,Post your comments below.