Created
August 30, 2012 10:45
-
-
Save kathangeorg/3526107 to your computer and use it in GitHub Desktop.
1und1 file_get_content() Alternative cURL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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