Copy CoroutineGen :: runNonBlocking (
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!" ) ;
}
) ;
Copy string(6) "START!"
string(12) "Hello World!"
string(10989) "<!DOCTYPE HTML>
<html>
<head> ...."
string(4) "END!"
Copy function a () {
for ($i = 0 ; $i <= 5 ; $i ++ ) {
yield var_dump ( "A" ) ;
}
}
function b () {
for ($i = 0 ; $i <= 5 ; $i ++ ) {
yield var_dump ( "B" ) ;
}
}
CoroutineGen :: runNonBlocking (
a (),
b (),
function () {
var_dump ( "C" ) ;
}
) ;
var_dump ( "Running after coroutines" ) ;
Copy string(1) "C"
string(1) "A"
string(1) "A"
string(1) "B"
string(1) "B"
string(1) "A"
string(24) "Running after coroutines"
string(1) "B"
string(1) "A"
string(1) "B"
string(1) "A"
string(1) "B"
string(1) "A"
string(1) "B"