1$c = curl_init('https://yourURLhere.com');
2curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
3//curl_setopt(... other options you want...)
4
5$html = curl_exec($c);
6
7if (curl_error($c))
8 die(curl_error($c));
9
10// Get the status code
11$status = curl_getinfo($c, CURLINFO_HTTP_CODE);
12
13curl_close($c);
1Since PHP 5.1.0, file_put_contents() supports writing piece-by-piece by passing a stream-handle as the $data parameter:
2
3file_put_contents("Tmpfile.zip", fopen("http://someurl/file.zip", 'r'));
4From the manual:
5
6If data [that is the second argument] is a stream resource, the remaining buffer of that stream will be copied to the specified file. This is similar with using stream_copy_to_stream().
7
8(Thanks Hakre.)