Example #1
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use function chh\httpfetch\fetch;
fetch('http://www.example.com')->then(function ($response) {
    echo $response['status'], "\n";
});
fetch('http://www.example.com')->then(function ($response) {
    echo $response['status'], "\n";
});
Example #2
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use function chh\httpfetch\fetch;
$start = microtime(true);
$response1 = fetch('http://www.example.com', ['future' => 'lazy']);
$response2 = fetch('http://www.example.com', ['future' => 'lazy']);
echo microtime(true) - $start, "\n";
$start = microtime(true);
echo $response1['status'], "\n";
echo $response2['status'], "\n";
echo microtime(true) - $start, "\n";
Example #3
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use function chh\httpfetch\fetch;
$start = microtime(true);
$response1 = fetch('http://www.example.com', ['future' => false]);
echo $response1['status'], "\n";
$response2 = fetch('http://www.example.com', ['future' => false]);
echo $response2['status'], "\n";
echo microtime(true) - $start, "\n";
Example #4
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use function chh\httpfetch\fetch;
fetch('http://www.example.com')->then(function ($response) {
    echo $response['status'], "\n";
    return fetch('http://www.example.com');
})->then(function ($response) {
    echo $response['status'], "\n";
});