Below is the sample basic code for using the curl.
Below is the explanation of the above functions
<?php // create a new cURL resource $ch = curl_init();
// set URL and other appropriate options $options = array(CURLOPT_URL => 'http://www.example.com/',
CURLOPT_HEADER => false
);
curl_setopt_array($ch, $options);//curl_setopt($ch,CURLOPT_URL,'http://google.com'); You can use this line rather than the above two lines for initializing the URL. // grab URL and pass it to the browser curl_exec($ch);
// close cURL resource, and free up system resources curl_close($ch);?>
Below is the explanation of the above functions
- curl_init method used to initiate curl object.
- curl_setopt method for setting options to curl object
- CURLOPT_URL = Curl Option URL, here we need to set the remote server URL
- curl_exec method will execute the curl object.
- curl_setopt_array method used to send multiple parameters as an array.
No comments:
Post a Comment