CoroutineGen::runBlocking(
function() : \Generator {
$return = yield file_get_contents('http://www.weather.com.cn/data/cityinfo/101270101.html');
var_dump($return);
},
function() : \Generator {
yield var_dump("END!");
},
function() {
var_dump("START!");
},
function() {
var_dump("Hello World!");
}
);
$number = 0;
CoroutineGen::runBlocking(
function () use (&$number) {
for ($i = 0; $i < 1000; $i++) {
$number++;
yield;
}
},
function () use (&$number) {
for ($i = 0; $i < 5; $i++) {
var_dump("A");
yield;
}
},
function () use (&$number) {
for ($i = 0; $i < 5; $i++) {
var_dump("B");
yield;
}
}
);
echo $number;
string(1) "A"
string(1) "A"
string(1) "B"
string(1) "B"
string(1) "A"
string(1) "B"
string(1) "A"
string(1) "B"
string(1) "A"
string(1) "B"
1000