mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-10 10:26:35 +00:00
Unify Curl and MultiCurl examples
This commit is contained in:
@@ -5,3 +5,4 @@ use \Curl\Curl;
|
||||
|
||||
$curl = new Curl();
|
||||
$curl->download('https://secure.php.net/images/logos/php-med-trans.png', '/tmp/php-med-trans.png');
|
||||
$curl->download('https://upload.wikimedia.org/wikipedia/commons/c/c1/PHP_Logo.png', '/tmp/PHP_Logo.png');
|
||||
|
||||
+6
-3
@@ -3,10 +3,13 @@ require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use \Curl\Curl;
|
||||
|
||||
$curl = new Curl();
|
||||
$curl->download('https://secure.php.net/images/logos/php-med-trans.png', function ($instance, $tmpfile) {
|
||||
$callback = function ($instance, $tmpfile) {
|
||||
$save_to_path = '/tmp/' . basename($instance->url);
|
||||
$fh = fopen($save_to_path, 'wb');
|
||||
stream_copy_to_stream($tmpfile, $fh);
|
||||
fclose($fh);
|
||||
});
|
||||
};
|
||||
|
||||
$curl = new Curl();
|
||||
$curl->download('https://secure.php.net/images/logos/php-med-trans.png', $callback);
|
||||
$curl->download('https://upload.wikimedia.org/wikipedia/commons/c/c1/PHP_Logo.png', $callback);
|
||||
Reference in New Issue
Block a user