Skip to content

Instantly share code, notes, and snippets.

@kathangeorg
Created August 30, 2012 10:45
Show Gist options
  • Save kathangeorg/3526107 to your computer and use it in GitHub Desktop.
Save kathangeorg/3526107 to your computer and use it in GitHub Desktop.
1und1 file_get_content() Alternative cURL
Link: http://it.toolbox.com/wiki/index.php/Switch_from_file_get_contents_to_curl
------------------------------------------
------------------------------------------
Alter Code:
------------------------------------------
$data = file_get_contents($url);
Neuer Code:
------------------------------------------
//Initialize the Curl session
$ch = curl_init();
//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Set the URL
curl_setopt($ch, CURLOPT_URL, $url);
//Execute the fetch
$data = curl_exec($ch);
//Close the connection
curl_close($ch);
return $data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment