CURL in PHP (Client’s Uniform Resource Locator)

Curl is used to fetch the Remote content in to a file in  HTML format

<?php
$ch = curl_init(“http://www.google.com/&#8221;);
$fp = fopen(“sample.txt”, “w”);

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
?>

The Above code will retrieve content in HTML format from ‘www.google.com’ and store in the file named ‘sample.txt’.

 

Advertisements
Posted in PHP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s