Exemplo n.º 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";
});
Exemplo n.º 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";
Exemplo n.º 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";
Exemplo n.º 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";
});