Test if cURL is working Print

  • 37

Create a file called test-curl.php which includes the below script.
$ch = curl_init("http://www.google.com/");
$fp = fopen("google_homepage.txt", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
After you execute or load this page the script will create a google_homepage.txt within the same directory that includes the source of the Google homepage. If you see the text file populated with the html source code of google.com, cURL is working.

Was this answer helpful?

« Back