PHP code example of marius321967 / php-curl-class
1. Go to this page and download the library: Download marius321967/php-curl-class library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
marius321967 / php-curl-class example snippets
// Our response.
$response = null;
// Single Curl request object.
$curl = new Curl();
// Bind success callback.
$curl->success(function($curl) use (&$response) {
$response = $curl->response;
});
// Send the request.
$curl->get('http://example.com/');
echo $response;
// Our response.
$response = null;
// Async Curl handler.
$multiCurl = new MultiCurl();
// Add a get request to the queue, it returns the single request object.
$curl = $multiCurl->get('http://example.com/');
// Bind success callback.
$curl->success(function($curl) use (&$response) {
$response = $curl->response;
});
// Execute all requests in the queue.
$multiCurl->start();
echo $response;