示例#1
0
文件: async.php 项目: chh/httpfetch
<?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";
});
示例#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";
示例#3
0
文件: sync.php 项目: chh/httpfetch
<?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";
示例#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";
});